Skip to content

Commit

Permalink
ci: move local action test to a dedicated job
Browse files Browse the repository at this point in the history
  • Loading branch information
ferrarimarco committed May 7, 2024
1 parent fa75266 commit 40d8f51
Showing 1 changed file with 59 additions and 22 deletions.
81 changes: 59 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
permissions: {}

jobs:
test:
build-container-image:
name: Build and Test
runs-on: ubuntu-latest
permissions:
Expand Down Expand Up @@ -40,13 +40,6 @@ jobs:
with:
fetch-depth: 0

- name: Update action.yml
run: |
echo "yq version: $(yq --version)"
yq '.runs.image = env(CONTAINER_IMAGE_ID)' -i action.yml
echo "Action file contents:"
cat action.yml
- name: Set build metadata
run: |
if [[ ${{ github.event_name }} == 'push' ]] || [[ ${{ github.event_name }} == 'merge_group' ]]; then
Expand Down Expand Up @@ -112,6 +105,60 @@ jobs:
run: |
docker load <"/tmp/${{ env.CONTAINER_IMAGE_OUTPUT_IMAGE_NAME }}.tar"
# Validate the container image labels here so we don't have to pass the expected
# label values to other build jobs
- name: Validate container image labels
run: make validate-container-image-labels

- name: Upload ${{ env.CONTAINER_IMAGE_OUTPUT_IMAGE_NAME }} container image
uses: actions/upload-artifact@v4.3.3
with:
name: ${{ env.CONTAINER_IMAGE_OUTPUT_IMAGE_NAME }}
path: /tmp/${{ env.CONTAINER_IMAGE_OUTPUT_IMAGE_NAME }}.tar

test-local-action:
name: Test the Super-linter GitHub Action
runs-on: ubuntu-latest
needs: build-container-image
permissions:
contents: read
strategy:
matrix:
images:
- container-image-id: super-linter-latest
prefix: ""
target: standard
- container-image-id: super-linter-slim-latest
prefix: slim-
target: slim
env:
CONTAINER_IMAGE_ID: "ghcr.io/super-linter/super-linter:${{ matrix.images.prefix }}latest"
CONTAINER_IMAGE_TARGET: "${{ matrix.images.target }}"
CONTAINER_IMAGE_OUTPUT_IMAGE_NAME: "super-linter-${{ matrix.images.prefix }}latest"
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Download ${{ env.CONTAINER_IMAGE_OUTPUT_IMAGE_NAME }} container image
uses: actions/download-artifact@v4.1.7
with:
name: ${{ env.CONTAINER_IMAGE_OUTPUT_IMAGE_NAME }}
path: /tmp

- name: Load ${{ env.CONTAINER_IMAGE_OUTPUT_IMAGE_NAME }} container image
run: |
docker load --input /tmp/${{ env.CONTAINER_IMAGE_OUTPUT_IMAGE_NAME }}.tar
docker image ls -a
- name: Update action.yml
run: |
echo "yq version: $(yq --version)"
yq '.runs.image = env(CONTAINER_IMAGE_ID)' -i action.yml
echo "Action file contents:"
cat action.yml
- name: Test Local Action (debug log)
uses: ./
env:
Expand All @@ -138,21 +185,9 @@ jobs:
FILTER_REGEX_EXCLUDE: ".*(/test/linters/|CHANGELOG.md).*"
TYPESCRIPT_STANDARD_TSCONFIG_FILE: ".github/linters/tsconfig.json"

# Validate the container image labels here so we don't have to pass the expected
# label values to other build jobs
- name: Validate container image labels
run: make validate-container-image-labels

- name: Upload ${{ env.CONTAINER_IMAGE_OUTPUT_IMAGE_NAME }} container image
uses: actions/upload-artifact@v4.3.3
with:
name: ${{ env.CONTAINER_IMAGE_OUTPUT_IMAGE_NAME }}
path: /tmp/${{ env.CONTAINER_IMAGE_OUTPUT_IMAGE_NAME }}.tar

build-test-suite-matrix:
name: Build test suite matrix
runs-on: ubuntu-latest
needs: test
permissions:
contents: read
outputs:
Expand All @@ -174,7 +209,9 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: read
needs: build-test-suite-matrix
needs:
- build-container-image
- build-test-suite-matrix
strategy:
matrix:
test-case: ${{ fromJson(needs.build-test-suite-matrix.outputs.matrix) }}
Expand Down Expand Up @@ -220,7 +257,7 @@ jobs:
if: github.event_name == 'pull_request' && github.repository == github.event.pull_request.head.repo.full_name && github.repository == 'super-linter/super-linter'
runs-on: ubuntu-latest
permissions:
contents: read
contents: read
steps:
- uses: actions/checkout@v4
with:
Expand Down

0 comments on commit 40d8f51

Please sign in to comment.