molecule: use new nginx test image instead of running nginx component #516
Workflow file for this run
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
--- | |
name: Molecule Roles | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
types: | |
- opened | |
- reopened | |
- synchronize | |
- ready_for_review | |
jobs: | |
get_changed_roles: | |
if: github.event.pull_request.draft == false | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.changed-roles.outputs.all_changed_files }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Get changed roles | |
id: changed-roles | |
uses: tj-actions/changed-files@v41 | |
with: | |
json: true | |
escape_json: false | |
dir_names: true | |
dir_names_max_depth: 3 | |
files: | | |
playbooks/roles/**/** | |
- name: List all changed files | |
run: echo '${{ steps.changed-roles.outputs.all_changed_files }}' | |
molecule: | |
needs: [get_changed_roles] | |
if: ${{ needs.get_changed_roles.outputs.matrix != '[]' && needs.get_changed_roles.outputs.matrix != '' }} | |
runs-on: ubuntu-latest | |
env: | |
DOCKER_USER: ${{ github.actor }} | |
DOCKER_PW: ${{ secrets.GITHUB_TOKEN }} | |
DOCKER_REGISTRY: ghcr.io | |
ANSIBLE_FORCE_COLOR: '1' | |
ANSIBLE_STDOUT_CALLBACK: yaml | |
MOLECULE_CONFIG: ../../../molecule/ext/molecule-src/molecule.yml | |
REQUIREMENTS_FILE: molecule/ext/molecule-src/requirements.txt | |
ANSIBLE_REQUIREMENTS_FILE: molecule/ext/molecule-src/requirements.yml | |
CRUN_VER: 1.11.2 | |
strategy: | |
fail-fast: false | |
matrix: | |
roles: ${{ fromJSON(needs.get_changed_roles.outputs.matrix) }} | |
steps: | |
- name: Workaround crun issue on ubuntu # https://github.com/UtrechtUniversity/SRC-catalog-items/issues/3 | |
run: | | |
mkdir -p "${HOME}/.local/bin" | |
curl -L "https://github.com/containers/crun/releases/download/${CRUN_VER}/crun-${CRUN_VER}-linux-amd64" -o "${HOME}/.local/bin/crun" | |
chmod +x "${HOME}/.local/bin/crun" | |
crun --version | |
mkdir -p "${HOME}/.config/containers" | |
cat << EOF > "${HOME}/.config/containers/containers.conf" | |
[engine.runtimes] | |
crun = [ | |
"${HOME}/.local/bin/crun", | |
"/usr/bin/crun" | |
] | |
EOF | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
- run: pip install -r ${{ env.REQUIREMENTS_FILE }} | |
- run: ansible-galaxy install -r ${{ env.ANSIBLE_REQUIREMENTS_FILE }} | |
- run: ansible-galaxy install -r requirements.yml | |
- name: Molecule tests for role | |
run: | | |
cd ${{ matrix.roles }} && if [[ -d molecule ]]; then molecule -c ${{ env.MOLECULE_CONFIG }} test --all; fi |