Refactor tests to use a matrix

This commit is contained in:
Yoann Chaudet
2022-02-07 18:19:51 -08:00
parent 0305abd5bc
commit 45e128e769
+19 -194
View File
@@ -1,14 +1,14 @@
name: 'Test' name: "Test"
on: on:
push: push:
branches: branches:
- main - main
paths-ignore: paths-ignore:
- 'README.md' - "README.md"
pull_request: pull_request:
paths-ignore: paths-ignore:
- 'README.md' - "README.md"
env: env:
# Use docker.io for Docker Hub if empty # Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io REGISTRY: ghcr.io
@@ -34,11 +34,20 @@ jobs:
text: ${{ steps.grep-image-content.outputs.image }} text: ${{ steps.grep-image-content.outputs.image }}
regex: "jekyll-build-pages:(.*)'" regex: "jekyll-build-pages:(.*)'"
test-simple: test-builds:
needs: resolve-image-tag needs: resolve-image-tag
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: strategy:
TEST_NAME: simple matrix:
test:
- simple
- readme
- octicons
- mojombo
- themes
- jekyll-include-cache
- future-false
- future-true
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v2 uses: actions/checkout@v2
@@ -48,198 +57,14 @@ jobs:
context: . context: .
file: Dockerfile file: Dockerfile
tags: ${{ needs.resolve-image-tag.outputs.tag }} tags: ${{ needs.resolve-image-tag.outputs.tag }}
- name: Test ${{ env.TEST_NAME }} Project - name: Test ${{ matrix.name }} Project
uses: ./ uses: ./
with: with:
source: ./test_projects/${{ env.TEST_NAME }} source: ./test_projects/${{ matrix.name }}
destination: ./test_projects/${{ env.TEST_NAME }}/_site destination: ./test_projects/${{ matrix.name }}/_site
build_revision: JEKYLL_BUILD_REVISION build_revision: JEKYLL_BUILD_REVISION
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
- name: Verify output - name: Verify output
run: | run: |
./bin/compare_expected_output ./test_projects/${{env.TEST_NAME}} ./bin/compare_expected_output ./test_projects/${{matrix.name}}
test-readme:
needs: resolve-image-tag
runs-on: ubuntu-latest
env:
TEST_NAME: readme
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Build local docker image
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
tags: ${{ needs.resolve-image-tag.outputs.tag }}
- name: Test ${{ env.TEST_NAME }} Project
uses: ./
with:
source: ./test_projects/${{ env.TEST_NAME }}
destination: ./test_projects/${{ env.TEST_NAME }}/_site
build_revision: JEKYLL_BUILD_REVISION
token: ${{ secrets.GITHUB_TOKEN }}
- name: Verify output
run: |
./bin/compare_expected_output ./test_projects/${{env.TEST_NAME}}
test-octicons:
needs: resolve-image-tag
runs-on: ubuntu-latest
env:
TEST_NAME: octicons
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Build local docker image
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
tags: ${{ needs.resolve-image-tag.outputs.tag }}
- name: Test ${{ env.TEST_NAME }} Project
uses: ./
with:
source: ./test_projects/${{ env.TEST_NAME }}
destination: ./test_projects/${{ env.TEST_NAME }}/_site
build_revision: JEKYLL_BUILD_REVISION
token: ${{ secrets.GITHUB_TOKEN }}
- name: Verify output
run: |
./bin/compare_expected_output ./test_projects/${{env.TEST_NAME}}
test-mojombo:
needs: resolve-image-tag
runs-on: ubuntu-latest
env:
TEST_NAME: mojombo
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Build local docker image
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
tags: ${{ needs.resolve-image-tag.outputs.tag }}
- name: Test ${{ env.TEST_NAME }} Project
uses: ./
with:
source: ./test_projects/${{ env.TEST_NAME }}
destination: ./test_projects/${{ env.TEST_NAME }}/_site
build_revision: JEKYLL_BUILD_REVISION
token: ${{ secrets.GITHUB_TOKEN }}
- name: Verify output
run: |
./bin/compare_expected_output ./test_projects/${{env.TEST_NAME}}
test-themes:
needs: resolve-image-tag
runs-on: ubuntu-latest
env:
TEST_NAME: themes
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Build local docker image
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
tags: ${{ needs.resolve-image-tag.outputs.tag }}
- name: Test ${{ env.TEST_NAME }} Project
uses: ./
with:
source: ./test_projects/${{ env.TEST_NAME }}
destination: ./test_projects/${{ env.TEST_NAME }}/_site
build_revision: JEKYLL_BUILD_REVISION
token: ${{ secrets.GITHUB_TOKEN }}
- name: Verify output
run: |
./bin/compare_expected_output ./test_projects/${{env.TEST_NAME}}
test-jekyll-include-cache:
needs: resolve-image-tag
runs-on: ubuntu-latest
env:
TEST_NAME: jekyll-include-cache
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Build local docker image
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
tags: ${{ needs.resolve-image-tag.outputs.tag }}
- name: Test ${{ env.TEST_NAME }} Project
uses: ./
with:
source: ./test_projects/${{ env.TEST_NAME }}
destination: ./test_projects/${{ env.TEST_NAME }}/_site
build_revision: JEKYLL_BUILD_REVISION
token: ${{ secrets.GITHUB_TOKEN }}
- name: Verify output
run: |
./bin/compare_expected_output ./test_projects/${{env.TEST_NAME}}
test-future-false:
needs: resolve-image-tag
runs-on: ubuntu-latest
env:
TEST_NAME: future-false
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Build local docker image
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
tags: ${{ needs.resolve-image-tag.outputs.tag }}
- name: Test ${{ env.TEST_NAME }} Project
uses: ./
with:
source: ./test_projects/${{ env.TEST_NAME }}
destination: ./test_projects/${{ env.TEST_NAME }}/_site
build_revision: JEKYLL_BUILD_REVISION
token: ${{ secrets.GITHUB_TOKEN }}
- name: Verify output
run: |
./bin/compare_expected_output ./test_projects/${{env.TEST_NAME}}
test-future-true:
needs: resolve-image-tag
runs-on: ubuntu-latest
env:
TEST_NAME: future-true
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Build local docker image
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
tags: ${{ needs.resolve-image-tag.outputs.tag }}
- name: Test ${{ env.TEST_NAME }} Project
uses: ./
with:
source: ./test_projects/${{ env.TEST_NAME }}
destination: ./test_projects/${{ env.TEST_NAME }}/_site
build_revision: JEKYLL_BUILD_REVISION
token: ${{ secrets.GITHUB_TOKEN }}
- name: Verify output
run: |
./bin/compare_expected_output ./test_projects/${{env.TEST_NAME}}