ci: move local action test to a dedicated job (#5629)

This commit is contained in:
Marco Ferrari 2024-05-17 10:39:22 +02:00 committed by GitHub
parent 03b4aa0798
commit 90f3fef29d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 61 additions and 23 deletions

View file

@ -37,7 +37,8 @@
"**/test/linters/tekton/**", "**/test/linters/tekton/**",
"**/test/linters/typescript_es/**", "**/test/linters/typescript_es/**",
"**/github_conf/**", "**/github_conf/**",
"**/workflows/cd.yml" "**/workflows/cd.yml",
"**/workflows/ci.yml"
], ],
"reporters": [ "reporters": [
"consoleFull" "consoleFull"

View file

@ -10,7 +10,7 @@ on:
permissions: {} permissions: {}
jobs: jobs:
test: build-container-image:
name: Build and Test name: Build and Test
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
@ -40,13 +40,6 @@ jobs:
with: with:
fetch-depth: 0 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 - name: Set build metadata
run: | run: |
if [[ ${{ github.event_name }} == 'push' ]] || [[ ${{ github.event_name }} == 'merge_group' ]]; then if [[ ${{ github.event_name }} == 'push' ]] || [[ ${{ github.event_name }} == 'merge_group' ]]; then
@ -112,6 +105,60 @@ jobs:
run: | run: |
docker load <"/tmp/${{ env.CONTAINER_IMAGE_OUTPUT_IMAGE_NAME }}.tar" 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) - name: Test Local Action (debug log)
uses: ./ uses: ./
env: env:
@ -138,21 +185,9 @@ jobs:
FILTER_REGEX_EXCLUDE: ".*(/test/linters/|CHANGELOG.md).*" FILTER_REGEX_EXCLUDE: ".*(/test/linters/|CHANGELOG.md).*"
TYPESCRIPT_STANDARD_TSCONFIG_FILE: ".github/linters/tsconfig.json" 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: build-test-suite-matrix:
name: Build test suite matrix name: Build test suite matrix
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: test
permissions: permissions:
contents: read contents: read
outputs: outputs:
@ -174,7 +209,9 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
contents: read contents: read
needs: build-test-suite-matrix needs:
- build-container-image
- build-test-suite-matrix
strategy: strategy:
matrix: matrix:
test-case: ${{ fromJson(needs.build-test-suite-matrix.outputs.matrix) }} test-case: ${{ fromJson(needs.build-test-suite-matrix.outputs.matrix) }}
@ -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' 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 runs-on: ubuntu-latest
permissions: permissions:
contents: read contents: read
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with: