Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a #44

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 62 additions & 59 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
38 changes: 38 additions & 0 deletions .github/workflows/pr_body_check.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -585,3 +585,7 @@ messages:

print-%:
@echo $($*)

check-pr-body:
ansible-playbook -i localhost tools/ansible/check_pr.yml -eurl=${URL}

Empty file added a
Empty file.
46 changes: 46 additions & 0 deletions tools/ansible/check_pr.yml
Original file line number Diff line number Diff line change
@@ -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