Merge pull request #18 from Djontleman/master #101
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 | |
display-workflow-run-url-interval: 10s | |
display-workflow-run-url-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|should 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: 60s | |
display-workflow-run-url-interval: 10s | |
display-workflow-run-url-timeout: 60s | |
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|should 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 | |
display-workflow-run-url-interval: 10s | |
display-workflow-run-url-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|should 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 | |
display-workflow-run-url-interval: 10s | |
display-workflow-run-url-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 | |
parallel-runs-test: | |
needs: [build] | |
runs-on: ubuntu-latest | |
name: "parallel-runs-test [trigger+wait|by workflow filename|should succeed]" | |
strategy: | |
fail-fast: false | |
matrix: | |
environment: | |
- trunk | |
- staging | |
env: | |
RUN_NAME: ${{ github.repository }}/actions/runs/${{ github.run_id }}/envs/${{ matrix.environment }} | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
- name: Download dist | |
uses: actions/download-artifact@v3 | |
with: | |
name: build | |
path: dist | |
- name: Invoke 'named-run' workflow for this environment and wait for result using this action | |
id: named-run-workflow | |
uses: ./ | |
with: | |
workflow: named-run.yml | |
token: ${{ secrets.PERSONAL_TOKEN }} | |
run-name: ${{ env.RUN_NAME }} | |
wait-for-completion-interval: 10s | |
wait-for-completion-timeout: 120s | |
display-workflow-run-url-interval: 10s | |
display-workflow-run-url-timeout: 120s | |
workflow-logs: json-output | |
inputs: >- | |
{ | |
"run-name": "${{ env.RUN_NAME }}", | |
"environment": "${{ matrix.environment }}" | |
} | |
continue-on-error: true | |
- uses: nick-invision/assert-action@v1 | |
with: | |
expected: success | |
actual: ${{ steps.named-run-workflow.outputs.workflow-conclusion }} | |
- uses: nick-invision/assert-action@v1 | |
with: | |
expected: success | |
actual: ${{ steps.named-run-workflow.outcome }} | |
- uses: nick-invision/assert-action@v1 | |
env: | |
EXPECTED_LOG_MESSAGE: "### Env: ${{ matrix.environment }} ###" | |
with: | |
expected: true | |
actual: ${{ contains(fromJson(steps.named-run-workflow.outputs.workflow-logs).echo.*.message, env.EXPECTED_LOG_MESSAGE) }} | |
deploy: | |
needs: | |
- echo-1-test | |
- echo-2-test | |
- long-running-test | |
- failing-test | |
- timeout-test | |
- print-workflow-logs-test | |
- parallel-runs-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 }} | |