Skip to content

Commit

Permalink
Allow use as a reusable github action (#3513)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed Jun 22, 2023
1 parent e2c1247 commit 7ad36c6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,21 @@ jobs:
eco
py-devel
platforms: linux,macos

test-action:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Self test for ansible-lint@${{ github.action_ref || 'main' }}
uses: ./
with:
# basically we only lint linter own configuration, which should be passing.
args: .ansible-lint
build:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os || 'ubuntu-22.04' }}
needs: pre
needs:
- pre
- test-action
defaults:
run:
shell: ${{ matrix.shell || 'bash'}}
Expand Down Expand Up @@ -205,6 +215,7 @@ jobs:

needs:
- build
- test-action

runs-on: ubuntu-latest

Expand Down
30 changes: 10 additions & 20 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,8 @@ 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:
Expand All @@ -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 }}

0 comments on commit 7ad36c6

Please sign in to comment.