Skip to content

Commit

Permalink
Create separate github actions for various checks; get rid of monolit…
Browse files Browse the repository at this point in the history
…hic tox.yml (linux-system-roles#125)

* Create separate github actions for various checks; get rid of monolithic tox.yml

There are now separate github actions for the various tests, instead of all of
them being done as part of the tox tests in tox.yml - ansible-lint,
ansible-test, etc.

Use the officially supported github actions e.g. for ansible-lint, ansible-test,
rather than using our own from `tox-lsr` and trying to keep up with the latest
changes.  Developers will still be able to use `tox-lsr` on their local
development environments to run these tests in the same way that they are run in
github actions, so that errors found when submitting PRs can be reproduced and
corrected locally without too many github UI roundtrips.

Using separate github actions, and especially the official github actions which
generally have support for in-line comments, should help greatly with
readability and troubleshooting test results.

Python tests are removed from roles that do not use python.

Python tests are now done by python-unit-tests.yml which also does the black,
flake8, and pylint tests.

Signed-off-by: Rich Megginson <[email protected]>

* Create separate github actions for various checks; get rid of monolithic tox.yml

There are now separate github actions for the various tests, instead of all of
them being done as part of the tox tests in tox.yml - ansible-lint,
ansible-test, etc.

Use the officially supported github actions e.g. for ansible-lint, ansible-test,
rather than using our own from `tox-lsr` and trying to keep up with the latest
changes.  Developers will still be able to use `tox-lsr` on their local
development environments to run these tests in the same way that they are run in
github actions, so that errors found when submitting PRs can be reproduced and
corrected locally without too many github UI roundtrips.

Using separate github actions, and especially the official github actions which
generally have support for in-line comments, should help greatly with
readability and troubleshooting test results.

Python tests are removed from roles that do not use python.

Python tests are now done by python-unit-tests.yml which also does the black,
flake8, and pylint tests.

Signed-off-by: Rich Megginson <[email protected]>

* Create separate github actions for various checks; get rid of monolithic tox.yml

There are now separate github actions for the various tests, instead of all of
them being done as part of the tox tests in tox.yml - ansible-lint,
ansible-test, etc.

Use the officially supported github actions e.g. for ansible-lint, ansible-test,
rather than using our own from `tox-lsr` and trying to keep up with the latest
changes.  Developers will still be able to use `tox-lsr` on their local
development environments to run these tests in the same way that they are run in
github actions, so that errors found when submitting PRs can be reproduced and
corrected locally without too many github UI roundtrips.

Using separate github actions, and especially the official github actions which
generally have support for in-line comments, should help greatly with
readability and troubleshooting test results.

Python tests are removed from roles that do not use python.

Python tests are now done by python-unit-tests.yml which also does the black,
flake8, and pylint tests.

Signed-off-by: Rich Megginson <[email protected]>

Signed-off-by: Rich Megginson <[email protected]>
  • Loading branch information
richm authored Jan 26, 2023
1 parent 1fbb457 commit a347e0b
Show file tree
Hide file tree
Showing 10 changed files with 199 additions and 91 deletions.
15 changes: 9 additions & 6 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
---
skip_list:
- fqcn-builtins
exclude_paths:
- tests/roles/
- .github/
- examples/roles/
profile: production
kinds:
- yaml: "**/meta/collection-requirements.yml"
- yaml: "**/tests/collection-requirements.yml"
Expand All @@ -16,3 +11,11 @@ kinds:
- tasks: "**/tests/tasks/*/*.yml"
- vars: "**/tests/vars/*.yml"
- playbook: "**/examples/*.yml"
skip_list:
- fqcn-builtins
exclude_paths:
- tests/roles/
- .github/
- examples/roles/
mock_roles:
- linux-system-roles.kdump
33 changes: 33 additions & 0 deletions .github/workflows/ansible-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
name: Ansible Lint
on: # yamllint disable-line rule:truthy
pull_request:
push:
branches:
- main
workflow_dispatch:
jobs:
ansible_lint:
runs-on: ubuntu-latest
steps:
- name: Update pip, git
run: |
set -euxo pipefail
sudo apt-get update
sudo apt-get install -y git
- name: Checkout repo
uses: actions/checkout@v3
- name: Fix up role meta/main.yml namespace and name
run: |
set -euxo pipefail
mm=meta/main.yml
if [ -f "$mm" ]; then
if ! grep -q '^ *namespace:' "$mm"; then
sed "/galaxy_info:/a\ namespace: linux_system_roles" -i "$mm"
fi
if ! grep -q '^ *role_name:' "$mm"; then
sed "/galaxy_info:/a\ role_name: kdump" -i "$mm"
fi
fi
- name: Run ansible-lint
uses: ansible-community/ansible-lint-action@v6
28 changes: 28 additions & 0 deletions .github/workflows/ansible-managed-var-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: Check for ansible_managed variable use in comments
on: # yamllint disable-line rule:truthy
pull_request:
push:
branches:
- main
workflow_dispatch:
jobs:
ansible_managed_var_comment:
runs-on: ubuntu-latest
steps:
- name: Update pip, git
run: |
set -euxo pipefail
python3 -m pip install --upgrade pip
sudo apt-get update
sudo apt-get install -y git
- name: Checkout repo
uses: actions/checkout@v3
- name: Install tox, tox-lsr
run: |
set -euxo pipefail
pip3 install "git+https://github.com/linux-system-roles/[email protected]"
- name: Run ansible-plugin-scan
run: |
set -euxo pipefail
TOXENV=ansible-managed-var-comment lsr_ci_runtox
28 changes: 28 additions & 0 deletions .github/workflows/ansible-plugin-scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: Ansible Plugin Scan
on: # yamllint disable-line rule:truthy
pull_request:
push:
branches:
- main
workflow_dispatch:
jobs:
ansible_plugin_scan:
runs-on: ubuntu-latest
steps:
- name: Update pip, git
run: |
set -euxo pipefail
python3 -m pip install --upgrade pip
sudo apt-get update
sudo apt-get install -y git
- name: Checkout repo
uses: actions/checkout@v3
- name: Install tox, tox-lsr
run: |
set -euxo pipefail
pip3 install "git+https://github.com/linux-system-roles/[email protected]"
- name: Run ansible-plugin-scan
run: |
set -euxo pipefail
TOXENV=ansible-plugin-scan lsr_ci_runtox
50 changes: 50 additions & 0 deletions .github/workflows/ansible-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
name: Ansible Test
on: # yamllint disable-line rule:truthy
pull_request:
push:
branches:
- main
workflow_dispatch:
env:
LSR_ROLE2COLL_NAMESPACE: fedora
LSR_ROLE2COLL_NAME: linux_system_roles
jobs:
ansible_test:
runs-on: ubuntu-latest
steps:
- name: Update pip, git
run: |
set -euxo pipefail
python3 -m pip install --upgrade pip
sudo apt-get update
sudo apt-get install -y git
- name: Checkout repo
uses: actions/checkout@v3
- name: Install tox, tox-lsr
run: |
set -euxo pipefail
pip3 install "git+https://github.com/linux-system-roles/[email protected]"
- name: Convert role to collection format
run: |
set -euxo pipefail
TOXENV=collection lsr_ci_runtox
# copy the ignore files
coll_dir=".tox/ansible_collections/$LSR_ROLE2COLL_NAMESPACE/$LSR_ROLE2COLL_NAME"
# wokeignore:rule=sanity
ignore_dir="$coll_dir/tests/sanity"
if [ ! -d "$ignore_dir" ]; then
mkdir -p "$ignore_dir"
fi
# wokeignore:rule=sanity
for file in .sanity-ansible-ignore-*.txt; do
if [ -f "$file" ]; then
# wokeignore:rule=sanity
cp "$file" "$ignore_dir/${file//*.sanity-ansible-}"
fi
done
- name: Run ansible-test
uses: ansible-community/ansible-test-gh-action@release/v1
with:
testing-type: sanity # wokeignore:rule=sanity
collection-src-directory: .tox/ansible_collections/${{ env.LSR_ROLE2COLL_NAMESPACE }}/${{ env.LSR_ROLE2COLL_NAME }}
11 changes: 8 additions & 3 deletions .github/workflows/changelog_to_tag.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
# yamllint disable rule:line-length
name: Pushing CHANGELOG.md triggers tag, release, and Galaxy publish
name: Tag, release, and publish role based on CHANGELOG.md push
on: # yamllint disable-line rule:truthy
push:
branches:
- main
- master
paths:
- CHANGELOG.md
env:
Expand All @@ -13,8 +13,13 @@ jobs:
tag_release_publish:
runs-on: ubuntu-latest
steps:
- name: Update pip, git
run: |
set -euxo pipefail
sudo apt-get update
sudo apt-get install -y git
- name: checkout PR
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Get tag and message from the latest CHANGELOG.md commit
id: tag
run: |
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
name: ShellCheck
on: # yamllint disable-line rule:truthy
pull_request:
push:
branches:
- main
workflow_dispatch:
env:
# some scripts source tox-lsr scripts - suppress that check
SHELLCHECK_OPTS: -e SC1091
jobs:
shellcheck:
runs-on: ubuntu-latest
steps:
- name: Update git
run: |
set -euxo pipefail
sudo apt-get update
sudo apt-get install -y git
- name: Checkout repo
uses: actions/checkout@v3
- name: Run ShellCheck
id: shellcheck_id
uses: ludeeus/action-shellcheck@master
- name: Show file paths scanned
run: |
echo Files scanned:
echo "${{ steps.shellcheck_id.outputs.files }}"
59 changes: 0 additions & 59 deletions .github/workflows/tox.yml

This file was deleted.

35 changes: 13 additions & 22 deletions .github/workflows/weekly_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,35 @@ name: Weekly CI trigger
on: # yamllint disable-line rule:truthy
workflow_dispatch:
schedule:
- cron: '0 7 * * 6'
- cron: 0 7 * * 6
env:
BRANCH_NAME: "weekly-ci"
COMMIT_MESSAGE: "This PR is to trigger periodic CI testing"
BODY_MESSAGE: "This PR is for the purpose of triggering periodic CI testing. We don't currently have a way to trigger CI without a PR, so this PR serves that purpose."
BRANCH_NAME: weekly-ci
COMMIT_MESSAGE: This PR is to trigger periodic CI testing
BODY_MESSAGE: >-
This PR is for the purpose of triggering periodic CI testing.
We don't currently have a way to trigger CI without a PR,
so this PR serves that purpose.
COMMENT: "[citest]"
jobs:
weekly_ci:
runs-on: ubuntu-latest
steps:
- name: Update pip, git
run: |
set -euxo pipefail
sudo apt-get update
sudo apt-get install -y git
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Create and push empty commit
run: |
set -euxo pipefail
get_main_branch() {
local br
br=$(git branch --list main)
if [ -n "$br" ]; then
echo main
return 0
fi
br=$(git branch --list master)
if [ -n "$br" ]; then
echo master
return 0
fi
echo UNKNOWN
return 1
}
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git checkout ${{ env.BRANCH_NAME }} || git checkout -b ${{ env.BRANCH_NAME }}
git rebase $(get_main_branch)
git rebase main
git commit --allow-empty -m "${{ env.COMMIT_MESSAGE }}"
git push -f --set-upstream origin ${{ env.BRANCH_NAME }}
Expand Down
2 changes: 1 addition & 1 deletion .yamllint.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: MIT
---
extends: default
ignore: |
/.tox/
extends: default

0 comments on commit a347e0b

Please sign in to comment.