diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 74bc2122d9d2..8b9f131649ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,27 +18,30 @@ jobs: - name: api-test command: /start_tests.sh label: Run API Tests - - name: api-lint - command: /var/lib/awx/venv/awx/bin/tox -e linters - label: Run API Linters - - name: api-swagger - command: /start_tests.sh swagger - label: Generate API Reference - - name: awx-collection - command: /start_tests.sh test_collection_all - label: Run Collection Tests - - name: api-schema - label: Check API Schema - command: /start_tests.sh detect-schema-change SCHEMA_DIFF_BASE_BRANCH=${{ github.event.pull_request.base.ref }} - - name: ui-lint - label: Run UI Linters - command: make ui-lint - - name: ui-test-screens - label: Run UI Screens Tests - command: make ui-test-screens - - name: ui-test-general - label: Run UI General Tests - command: make ui-test-general +# - name: api-lint +# command: /var/lib/awx/venv/awx/bin/tox -e linters +# label: Run API Linters +# - name: api-swagger +# command: /start_tests.sh swagger +# label: Generate API Reference +# - name: awx-collection +# command: /start_tests.sh test_collection_all +# label: Run Collection Tests +# - name: api-schema +# label: Check API Schema +# command: /start_tests.sh detect-schema-change SCHEMA_DIFF_BASE_BRANCH=${{ github.event.pull_request.base.ref }} +# - name: ui-lint +# label: Run UI Linters +# command: make ui-lint +# - name: ui-test-screens +# label: Run UI Screens Tests +# command: make ui-test-screens +# - name: ui-test-general +# label: Run UI General Tests +# command: make ui-test-general +# - name: validate-pr-body +# label: Validate PR Body +# command: /start_tests.sh check-pr-body URL=${{ github.event.pull_request.url }} steps: - uses: actions/checkout@v2 @@ -97,41 +100,41 @@ jobs: export COMPOSE_TAG=${{ env.BRANCH }} ansible-playbook tools/docker-compose/ansible/smoke-test.yml -e repo_dir=$(pwd) -v - awx-operator: - runs-on: ubuntu-latest - steps: - - name: Checkout awx - uses: actions/checkout@v2 - with: - path: awx - - - name: Checkout awx-operator - uses: actions/checkout@v2 - with: - repository: ansible/awx-operator - path: awx-operator - - - name: Install playbook dependencies - run: | - python3 -m pip install docker setuptools_scm - - - name: Build AWX image - working-directory: awx - run: | - ansible-playbook -v tools/ansible/build.yml \ - -e headless=yes \ - -e awx_image=awx \ - -e awx_image_tag=ci \ - -e ansible_python_interpreter=$(which python3) - - - name: Run test deployment with awx-operator - working-directory: awx-operator - run: | - python3 -m pip install -r molecule/requirements.txt - ansible-galaxy collection install -r molecule/requirements.yml - sudo rm -f $(which kustomize) - make kustomize - KUSTOMIZE_PATH=$(readlink -f bin/kustomize) molecule -v test -s kind - env: - AWX_TEST_IMAGE: awx - AWX_TEST_VERSION: ci +# awx-operator: +# runs-on: ubuntu-latest +# steps: +# - name: Checkout awx +# uses: actions/checkout@v2 +# with: +# path: awx +# +# - name: Checkout awx-operator +# uses: actions/checkout@v2 +# with: +# repository: ansible/awx-operator +# path: awx-operator +# +# - name: Install playbook dependencies +# run: | +# python3 -m pip install docker setuptools_scm +# +# - name: Build AWX image +# working-directory: awx +# run: | +# ansible-playbook -v tools/ansible/build.yml \ +# -e headless=yes \ +# -e awx_image=awx \ +# -e awx_image_tag=ci \ +# -e ansible_python_interpreter=$(which python3) +# +# - name: Run test deployment with awx-operator +# working-directory: awx-operator +# run: | +# python3 -m pip install -r molecule/requirements.txt +# ansible-galaxy collection install -r molecule/requirements.yml +# sudo rm -f $(which kustomize) +# make kustomize +# KUSTOMIZE_PATH=$(readlink -f bin/kustomize) molecule -v test -s kind +# env: +# AWX_TEST_IMAGE: awx +# AWX_TEST_VERSION: ci diff --git a/.github/workflows/pr_body_check.yml b/.github/workflows/pr_body_check.yml new file mode 100644 index 000000000000..c1e5bcc07e2d --- /dev/null +++ b/.github/workflows/pr_body_check.yml @@ -0,0 +1,38 @@ +--- +name: PR Check +env: + BRANCH: ${{ github.base_ref || 'devel' }} +on: + pull_request: +jobs: + pr-check: + name: Check PR for X,Y,Z properties + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + steps: + - name: Write PR body to a file + run: | + cat >> pr.body << __SOME_RANDOM_PR_EOF__ + ${{ github.event.pull_request.body }} + __SOME_RANDOM_PR_EOF__ + + # We want to write these out individually just incase the options were joined on a single line + - name: Check for each of the lines + run: | + # Prevent us from failing if grep gives a non-0 return code (which can happen depending on the number of matches) + set +e + grep "Bug or Docs Fix" pr.body > Z + grep "New or Enhanced Feature" pr.body > Y + grep "Breaking Change" pr.body > X + + - name: Check for exactly one item + run: | + if [ $(cat X Y Z | wc -l) != 1 ] ; then + echo "The PR body must contain exactly one of [ 'Bug or Docs Fix', 'New or Enhanced Feature', 'Breaking Change' ]" + echo "We counted $(cat X Y Z | wc -l)" + exit 255; + else + exit 0; + fi diff --git a/Makefile b/Makefile index 3de0fc766ada..dd2c27482850 100644 --- a/Makefile +++ b/Makefile @@ -585,3 +585,7 @@ messages: print-%: @echo $($*) + +check-pr-body: + ansible-playbook -i localhost tools/ansible/check_pr.yml -eurl=${URL} + diff --git a/a b/a new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tools/ansible/check_pr.yml b/tools/ansible/check_pr.yml new file mode 100644 index 000000000000..4bb8ac91ed2b --- /dev/null +++ b/tools/ansible/check_pr.yml @@ -0,0 +1,46 @@ +--- +- name: Check an AWX PR + hosts: localhost + connection: local + gather_facts: False + vars: + change_strings: + - Breaking Change + - New or Enhanced Feature + - Bug or Docs Fix + is_x: True + is_y: True + is_z: True + tasks: + - name: Fail if URL is not provided + fail: + msg: "The URL to the PR must be passed into this playbook" + when: "url is not defined or url == ''" + + - name: Get the PR information + uri: + url: https://api.github.com/repos/john-westcott-iv/awx/pulls/28 + register: pr_info + + - debug: + msg: "{{ pr_info['json']['body'] | split('\n') }}" + + - name: Check PR body for strings + set_fact: + checks: "{{ [ (is_x | ternary('yes', 'no')), (is_y | ternary('yes', 'no')), (is_z | ternary('yes', 'no')) ] }}" + vars: + body: "{{ pr_info['json']['body'] }}" + is_x: "{{ change_strings[0] in body }}" + is_y: "{{ change_strings[1] in body }}" + is_z: "{{ change_strings[2] in body }}" + + - debug: + msg: + - "{{ counts }}" + - "{{ counts.get('yes', 0) }}" + vars: + counts: "{{ checks | community.general.counter }}" + + - fail: + msg: "The PR body must have exactly one of {{ change_strings | join(', ') }}" + when: (checks | community.general.counter).get('yes', 0) != 1