Skip to content

Commit

Permalink
Improve testing of github action
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed Sep 19, 2024
1 parent 9d63816 commit 6f0520c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
15 changes: 14 additions & 1 deletion .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,24 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Self test for ansible-lint@${{ github.action_ref || 'main' }}
- name: Self test 1
uses: ./
with:
# basically we only lint linter own configuration, which should be passing.
args: .ansible-lint
- name: Self test 2
uses: ./
with:
# basically we only lint linter own configuration, which should be passing.
args: .ansible-lint
working_directory: .
- name: Self test 3
uses: ./
with:
# basically we only lint linter own configuration, which should be passing.
args: .ansible-lint
working_directory: docs
expected_return_code: "2" # expected to fail because the given argument does not exist in this folder
build:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os || 'ubuntu-22.04' }}
Expand Down
12 changes: 10 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ inputs:
description: Path to the requirements YAML file to install role and collection dependencies.
required: false
default: ""
expected_return_code:
description: Expected return code from ansible-lint. Default is 0. Used for self-testing purposes.
required: false
default: "0"
runs:
using: composite
steps:
Expand All @@ -46,7 +50,7 @@ runs:
GH_ACTION_REF: ${{ github.action_ref || 'main' }}
working-directory: ${{ steps.inputs.outputs.working_directory }}
run: |
wget --output-document=${{ steps.inputs.outputs.working_directory }}/.git/ansible-lint-requirements.txt https://raw.githubusercontent.com/ansible/ansible-lint/$GH_ACTION_REF/.config/requirements-lock.txt
wget --output-document=.git/ansible-lint-requirements.txt https://raw.githubusercontent.com/ansible/ansible-lint/$GH_ACTION_REF/.config/requirements-lock.txt
- name: Set up Python
if: inputs.setup_python == 'true'
Expand Down Expand Up @@ -78,4 +82,8 @@ runs:
- name: Run ansible-lint
shell: bash
working-directory: ${{ steps.inputs.outputs.working_directory }}
run: ansible-lint ${{ inputs.args }}
run: |
exit_code=0
expected_exit_code=${{ inputs.expected_return_code }}
ansible-lint ${{ inputs.args }} || exit_code=$?
if [ "$exit_code" != "$expected_exit_code" ]; then echo "Command failed: got '$exit_code', expected '$expected_exit_code'"; exit 1; fi
2 changes: 1 addition & 1 deletion src/ansiblelint/schemas/__store__.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/inventory.json"
},
"meta": {
"etag": "fdff861b226b13b711dd7f94301ed5becd6dc5d8d4e872f909d4a3d8133d600a",
"etag": "57fd2147c4c70dfd7dea6b3960bb8ed910c01c693de168cc7ac2b8cf527a1166",
"url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/meta.json"
},
"meta-runtime": {
Expand Down

0 comments on commit 6f0520c

Please sign in to comment.