-
Notifications
You must be signed in to change notification settings - Fork 672
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add self testing - fixes current problems preventing use as an action - make use of pip caching for linter requirements
- Loading branch information
Showing
2 changed files
with
24 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,13 @@ | ||
--- | ||
name: ansible-lint-action | ||
name: run-ansible-lint | ||
description: Run Ansible Lint | ||
author: Ansible by Red Hat <[email protected]> | ||
branding: | ||
icon: shield | ||
color: red | ||
inputs: | ||
path: | ||
description: > | ||
Specific path to lint instead of the default `.`. Multiple arguments are | ||
not supported and you will need to alter linter configuration to | ||
accommodate other use cases. | ||
required: false | ||
# That default is just a placeholder workaround for no arguments use-case | ||
# Feeding "." or empty string to ansible-lint makes it believe it is a role | ||
default: --show-relpath | ||
args: | ||
description: deprecated | ||
deprecationMessage: > | ||
Arbitrary args are no longer accepted, please use path instead and | ||
linter own configuration file to change its behavior. | ||
description: Arguments to be passed to ansible-lint command | ||
required: false | ||
default: "" | ||
runs: | ||
|
@@ -30,27 +18,29 @@ runs: | |
fetch-depth: 0 # needed by setuptools-scm | ||
submodules: true | ||
|
||
- name: Generate ansible-lint-requirements.txt | ||
shell: bash | ||
run: | | ||
wget --output-file=$HOME/requirements.txt https://raw.githubusercontent.com/ansible/ansible-lint/${{ github.action_ref || 'main' }}/.config/requirements-lock.txt | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
cache: pip | ||
# As setting cache to pip fails if there is no requirements.txt, we | ||
# trick it to also load /dev/null to avoid failure for no requirements. | ||
cache-dependency-path: | | ||
**/requirements*.txt | ||
/dev/null | ||
cache-dependency-path: ~/requirements.txt | ||
python-version: "3.11" | ||
|
||
- name: Install ansible-lint | ||
shell: bash | ||
# We need to set the version manually because $GITHUB_ACTION_PATH is not | ||
# a git clone and setuptools-scm would not be able to determine the version. | ||
# git+https://github.com/ansible/ansible-lint@${{ github.action_ref || 'main' }} | ||
# SETUPTOOLS_SCM_PRETEND_VERSION=${{ github.action_ref || 'main' }} | ||
run: | | ||
cd $GITHUB_ACTION_PATH | ||
SETUPTOOLS_SCM_PRETEND_VERSION=${{ github.action_ref || 'main' }} pip install ".[lock]" | ||
pip install "ansible-lint[lock] @ git+https://github.com/ansible/ansible-lint@${{ github.action_ref || 'main' }}" | ||
ansible-lint --version | ||
- name: Run ansible-lint | ||
shell: bash | ||
run: ansible-lint ${{ inputs.path }} | ||
run: ansible-lint ${{ inputs.args }} |