Skip to content

Commit

Permalink
do not run redundant test action on master events; reuse prebuilt bas…
Browse files Browse the repository at this point in the history
…e image in test actions
  • Loading branch information
bitmeal committed Mar 21, 2022
1 parent e31740e commit d31b1a4
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 17 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build fission:base image

# do not run automatically
on:
workflow_call:
workflow_dispatch:

jobs:
build:
name: Build fission:base image
runs-on: ubuntu-latest
steps:
-
name: Clone
uses: actions/checkout@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Build and export
uses: docker/build-push-action@v2
with:
context: .
tags: fission:base
outputs: type=docker,dest=/tmp/fission.tar
-
name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: fission_base_image
path: /tmp/fission.tar
22 changes: 22 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# run on non-master branches, and pull requests

name: Perform automated Checks (non-master-branch events)

on:
push:
branches-ignore:
- master
pull_request:
workflow_call:
workflow_dispatch:

jobs:
build:
name: Build fission:base image
uses: ./.github/workflows/build.yaml

test:
name: Run Tests
needs:
- build
uses: ./.github/workflows/test.yaml
46 changes: 39 additions & 7 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
name: Deploy Container
# run on master

name: Run Tests and deploy Container

on:
push:
Expand All @@ -9,10 +11,18 @@ on:
workflow_dispatch:

jobs:
build:
name: Build fission:base image
uses: ./.github/workflows/build.yaml

test:
name: Run Tests
needs:
- build
uses: ./.github/workflows/test.yaml

prepare:
name: Prepare versioning variables from tag
needs:
- test
runs-on: ubuntu-latest
Expand All @@ -36,6 +46,7 @@ jobs:
run: "echo tag string: ${{ steps.version.outputs.num }}; echo is tag: ${{ steps.tag.outputs.truthy }}"

report:
name: Build status badges from test status
if: ${{ always() }}
runs-on: ubuntu-latest
strategy:
Expand All @@ -49,22 +60,29 @@ jobs:
needs:
- test
steps:
- uses: actions/checkout@v2
- name: Setup Node.js
-
name: Clone
uses: actions/checkout@v2
-
name: Setup Node.js
uses: actions/setup-node@v2
with:
check-latest: true
- name: Fetch Dependencies
-
name: Fetch Dependencies
working-directory: helpers
run: sudo apt install -qq -y jq && npm ci
- name: Fetch matrix jobs status artifacts
-
name: Fetch matrix jobs status artifacts
uses: actions/download-artifact@v2
with:
path: platforms
- name: Build Matrix Badges
-
name: Build Matrix Badges
run: |
jq -s '.' platforms/status/init_${{ matrix.init }}/*.json | node helpers/badgebuilder.js > badges_init-${{ matrix.init }}.svg
- name: Deploy Badges
-
name: Deploy Badges
uses: exuanbo/actions-deploy-gist@v1
with:
token: ${{ secrets.GIST_TOKEN }}
Expand All @@ -74,6 +92,7 @@ jobs:
file_path: ./badges_init-${{ matrix.init }}.svg

docker:
name: Push versioned/tagged fission:base docker image to ghcr.io
needs:
- test
- prepare
Expand All @@ -93,6 +112,19 @@ jobs:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Fetch prebuilt base image
uses: actions/download-artifact@v2
continue-on-error: true
with:
name: fission_base_image
path: /tmp
-
name: Load prebuilt base image
continue-on-error: true
run: |
docker load --input /tmp/fission.tar
docker image ls -a
-
name: Build and push x64 image to ghcr.io
run: docker buildx build --push --tag "ghcr.io/bitmeal/fission:$([[ ${{ needs.prepare.outputs.tag }} == 'true' ]] && echo latest || echo edge)" $([[ ${{ needs.prepare.outputs.tag }} == 'true' ]] && echo "--tag ghcr.io/bitmeal/fission:${{ needs.prepare.outputs.version }}") .
39 changes: 29 additions & 10 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
name: Run Tests

# do not run automatically
on:
push:
pull_request:
workflow_call:
workflow_dispatch:


jobs:
test:
name: Run Tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -26,34 +27,52 @@ jobs:
env:
FISSION_DOCKER_INIT: ${{ matrix.init }}
steps:
-
-
name: Fetch Dependencies
run: sudo apt install -qq -y jq moreutils

-
name: Clone
uses: actions/checkout@v2
-
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Fetch prebuilt base image
uses: actions/download-artifact@v2
continue-on-error: true
with:
name: fission_base_image
path: /tmp
-
name: Load prebuilt base image
continue-on-error: true
run: |
docker load --input /tmp/fission.tar
docker image ls -a
-
name: Run Tests
working-directory: test
env:
FISSION_PLATFORM: ${{ matrix.platform }}
run: ./test.bash -t

- name: "Prepare status artifact [${{ matrix.platform }}][init: ${{ matrix.init }}]"
-
name: "Prepare status artifact [${{ matrix.platform }}][init: ${{ matrix.init }}]"
if: ${{ always() }}
run: |
mkdir -p status/init_${{ matrix.init }} &&
echo '{}' | jq --arg job "${{ matrix.platform }}" '. + {job: $job}' > status/init_${{ matrix.init }}/${{ matrix.platform }}.json
- name: Finalize status artifact @success
-
name: Finalize status artifact @success
if: ${{ success() }}
run: |
cat status/init_${{ matrix.init }}/${{ matrix.platform }}.json | jq --argjson success true '. + {success: $success}' | sponge status/init_${{ matrix.init }}/${{ matrix.platform }}.json
- name: Finalize status artifact @failure
-
name: Finalize status artifact @failure
if: ${{ failure() }}
run: |
cat status/init_${{ matrix.init }}/${{ matrix.platform }}.json | jq --argjson success false '. + {success: $success}' | sponge status/init_${{ matrix.init }}/${{ matrix.platform }}.json
- name: Upload status artifact [${{ matrix.platform }}.json]
-
name: Upload status artifact [${{ matrix.platform }}.json]
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v2
with:
Expand Down

0 comments on commit d31b1a4

Please sign in to comment.