Skip to content

Commit 7ad36c6

Browse files
authored
Allow use as a reusable github action (#3513)
1 parent e2c1247 commit 7ad36c6

2 files changed

Lines changed: 23 additions & 22 deletions

File tree

.github/workflows/tox.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,21 @@ jobs:
3939
eco
4040
py-devel
4141
platforms: linux,macos
42-
42+
test-action:
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v3
46+
- name: Self test for ansible-lint@${{ github.action_ref || 'main' }}
47+
uses: ./
48+
with:
49+
# basically we only lint linter own configuration, which should be passing.
50+
args: .ansible-lint
4351
build:
4452
name: ${{ matrix.name }}
4553
runs-on: ${{ matrix.os || 'ubuntu-22.04' }}
46-
needs: pre
54+
needs:
55+
- pre
56+
- test-action
4757
defaults:
4858
run:
4959
shell: ${{ matrix.shell || 'bash'}}
@@ -205,6 +215,7 @@ jobs:
205215

206216
needs:
207217
- build
218+
- test-action
208219

209220
runs-on: ubuntu-latest
210221

action.yml

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,8 @@ branding:
66
icon: shield
77
color: red
88
inputs:
9-
path:
10-
description: >
11-
Specific path to lint instead of the default `.`. Multiple arguments are
12-
not supported and you will need to alter linter configuration to
13-
accommodate other use cases.
14-
required: false
15-
# That default is just a placeholder workaround for no arguments use-case
16-
# Feeding "." or empty string to ansible-lint makes it believe it is a role
17-
default: --show-relpath
189
args:
19-
description: deprecated
20-
deprecationMessage: >
21-
Arbitrary args are no longer accepted, please use path instead and
22-
linter own configuration file to change its behavior.
10+
description: Arguments to be passed to ansible-lint command
2311
required: false
2412
default: ""
2513
runs:
@@ -30,27 +18,29 @@ runs:
3018
fetch-depth: 0 # needed by setuptools-scm
3119
submodules: true
3220

21+
- name: Generate ansible-lint-requirements.txt
22+
shell: bash
23+
run: |
24+
wget --output-file=$HOME/requirements.txt https://raw.githubusercontent.com/ansible/ansible-lint/${{ github.action_ref || 'main' }}/.config/requirements-lock.txt
25+
3326
- name: Set up Python
3427
uses: actions/setup-python@v4
3528
with:
3629
cache: pip
37-
# As setting cache to pip fails if there is no requirements.txt, we
38-
# trick it to also load /dev/null to avoid failure for no requirements.
39-
cache-dependency-path: |
40-
**/requirements*.txt
41-
/dev/null
30+
cache-dependency-path: ~/requirements.txt
4231
python-version: "3.11"
4332

4433
- name: Install ansible-lint
4534
shell: bash
4635
# We need to set the version manually because $GITHUB_ACTION_PATH is not
4736
# a git clone and setuptools-scm would not be able to determine the version.
4837
# git+https://github.com/ansible/ansible-lint@${{ github.action_ref || 'main' }}
38+
# SETUPTOOLS_SCM_PRETEND_VERSION=${{ github.action_ref || 'main' }}
4939
run: |
5040
cd $GITHUB_ACTION_PATH
51-
SETUPTOOLS_SCM_PRETEND_VERSION=${{ github.action_ref || 'main' }} pip install ".[lock]"
41+
pip install "ansible-lint[lock] @ git+https://github.com/ansible/ansible-lint@${{ github.action_ref || 'main' }}"
5242
ansible-lint --version
5343
5444
- name: Run ansible-lint
5545
shell: bash
56-
run: ansible-lint ${{ inputs.path }}
46+
run: ansible-lint ${{ inputs.args }}

0 commit comments

Comments
 (0)