Build & Test #2
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: Build & Test | |
on: | |
push: | |
branches: [ master ] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '20' | |
- name: Build with ncc | |
run: | | |
npm install -g yarn | |
yarn install | |
yarn run build | |
- name: Archive dist | |
uses: actions/upload-artifact@v3 | |
with: | |
name: build | |
path: dist | |
echo-1-test: | |
needs: [build] | |
runs-on: ubuntu-latest | |
name: "echo-1-test [trigger|by workflow name]" | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
- name: Download dist | |
uses: actions/download-artifact@v3 | |
with: | |
name: build | |
path: dist | |
- name: Invoke echo 1 workflow using this action (do not wait for completion) | |
uses: ./ | |
with: | |
workflow: Message Echo 1 | |
token: ${{ secrets.PERSONAL_TOKEN }} | |
inputs: '{"message": "blah blah"}' | |
wait-for-completion: false | |
echo-2-test: | |
needs: [build] | |
runs-on: ubuntu-latest | |
name: "echo-2-test [trigger|by workflow filename]" | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
- name: Download dist | |
uses: actions/download-artifact@v3 | |
with: | |
name: build | |
path: dist | |
- name: Invoke echo 2 workflow using this action | |
uses: ./ | |
with: | |
workflow: echo-2.yaml | |
token: ${{ secrets.PERSONAL_TOKEN }} | |
wait-for-completion: false | |
# - name: Invoke echo 1 workflow by id | |
# uses: ./ | |
# with: | |
# workflow: '1854247' | |
# token: ${{ secrets.PERSONAL_TOKEN }} | |
# inputs: '{"message": "Mango jam"}' | |
# wait-for-completion: false | |
long-running-test: | |
needs: [build] | |
runs-on: ubuntu-latest | |
name: "long-running-test [trigger+wait|by workflow filename|shoud succeed]" | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
- name: Download dist | |
uses: actions/download-artifact@v3 | |
with: | |
name: build | |
path: dist | |
- name: Invoke 'long-running' workflow and wait for result using this action | |
id: long-running-workflow | |
uses: ./ | |
with: | |
workflow: long-running.yml | |
token: ${{ secrets.PERSONAL_TOKEN }} | |
wait-for-completion-interval: 10s | |
wait-for-completion-timeout: 5m | |
continue-on-error: true | |
- uses: nick-invision/assert-action@v1 | |
with: | |
expected: success | |
actual: ${{ steps.long-running-workflow.outputs.workflow-conclusion }} | |
- uses: nick-invision/assert-action@v1 | |
with: | |
expected: success | |
actual: ${{ steps.long-running-workflow.outcome }} | |
failing-test: | |
needs: [build] | |
runs-on: ubuntu-latest | |
name: "failing-test [trigger+wait|by workflow filename|shoud report failure]" | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
- name: Download dist | |
uses: actions/download-artifact@v3 | |
with: | |
name: build | |
path: dist | |
- name: Invoke 'failing' workflow and wait for result using this action | |
id: failing-workflow | |
uses: ./ | |
with: | |
workflow: failing.yml | |
token: ${{ secrets.PERSONAL_TOKEN }} | |
wait-for-completion-interval: 10s | |
wait-for-completion-timeout: 5m | |
continue-on-error: true | |
- run: echo "worflow-conclusion=${{ steps.failing-workflow.outputs.workflow-conclusion }}" | |
- uses: nick-invision/assert-action@v1 | |
with: | |
expected: failure | |
actual: ${{ steps.failing-workflow.outputs.workflow-conclusion }} | |
- uses: nick-invision/assert-action@v1 | |
with: | |
expected: failure | |
actual: ${{ steps.failing-workflow.outcome }} | |
timeout-test: | |
needs: [build] | |
runs-on: ubuntu-latest | |
name: "timeout-test [trigger+wait|by workflow filename|shoud report timed_out]" | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
- name: Download dist | |
uses: actions/download-artifact@v3 | |
with: | |
name: build | |
path: dist | |
- name: Invoke 'timeout' workflow and wait for result using this action | |
id: timeout-workflow | |
uses: ./ | |
with: | |
workflow: timeout.yml | |
token: ${{ secrets.PERSONAL_TOKEN }} | |
wait-for-completion-interval: 10s | |
wait-for-completion-timeout: 30s | |
continue-on-error: true | |
- uses: nick-invision/assert-action@v1 | |
with: | |
expected: timed_out | |
actual: ${{ steps.timeout-workflow.outputs.workflow-conclusion }} | |
- uses: nick-invision/assert-action@v1 | |
with: | |
expected: failure | |
actual: ${{ steps.timeout-workflow.outcome }} | |
print-workflow-logs-test: | |
needs: [build] | |
runs-on: ubuntu-latest | |
name: "print-workflow-logs-test [trigger+wait|by workflow filename|print logs|shoud report timed_out]" | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
- name: Download dist | |
uses: actions/download-artifact@v3 | |
with: | |
name: build | |
path: dist | |
- name: Invoke 'retrieve-logs' workflow and wait for result using this action | |
id: print-workflow-logs | |
uses: ./ | |
with: | |
workflow: retrieve-logs.yml | |
token: ${{ secrets.PERSONAL_TOKEN }} | |
wait-for-completion-interval: 10s | |
wait-for-completion-timeout: 120s | |
workflow-logs: print | |
continue-on-error: true | |
- uses: nick-invision/assert-action@v1 | |
with: | |
expected: timed_out | |
actual: ${{ steps.print-workflow-logs.outputs.workflow-conclusion }} | |
- uses: nick-invision/assert-action@v1 | |
with: | |
expected: failure | |
actual: ${{ steps.print-workflow-logs.outcome }} | |
# TODO: add assertions on logs | |
# - name: Invoke external workflow using this action | |
# uses: ./ | |
# with: | |
# workflow: Deploy To Kubernetes | |
# repo: benc-uk/dapr-store | |
# token: ${{ secrets.PERSONAL_TOKEN }} | |
# ref: master | |
deploy: | |
needs: | |
- echo-1-test | |
- echo-2-test | |
- long-running-test | |
- failing-test | |
- timeout-test | |
- print-workflow-logs-test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
- name: Download dist | |
uses: actions/download-artifact@v3 | |
with: | |
name: build | |
path: dist | |
- name: Update repo with build | |
uses: mikeal/publish-to-github-action@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |