From 8e26ce29fb0d313a0f2d57c864c664aaf8038fe8 Mon Sep 17 00:00:00 2001 From: Samuel Khuvis Date: Wed, 4 Dec 2024 23:50:29 -0800 Subject: [PATCH] Successful image build triggers test suite --- .github/workflows/test_suite.yml | 56 ++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/test_suite.yml diff --git a/.github/workflows/test_suite.yml b/.github/workflows/test_suite.yml new file mode 100644 index 0000000..cea843d --- /dev/null +++ b/.github/workflows/test_suite.yml @@ -0,0 +1,56 @@ +name: Test Suite + +on: + workflow_run: + workflows: ["Docker Image CI"] + types: + - completed + +jobs: + Test_Suite: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + steps: + - name: 'Download artifact' + uses: actions/github-script@v7 + with: + script: | + let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: context.payload.workflow_run.id, + }); + let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { + return artifact.name == "testinfo" + })[0]; + let download = await github.rest.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: matchArtifact.id, + archive_format: 'zip', + }); + const fs = require('fs'); + const path = require('path'); + const temp = '${{ runner.temp }}/artifacts'; + if (!fs.existsSync(temp)){ + fs.mkdirSync(temp); + } + fs.writeFileSync(path.join(temp, 'testinfo.zip'), Buffer.from(download.data)); + - name: Unzip artifact + run: unzip "${{ runner.temp }}/artifacts/testinfo.zip" -d "${{ runner.temp }}/artifacts" + - name: Trigger Test Suite github action + run: | + if [[ ${{ github.event_name == 'release' }} == true ]]; then + CTVER=${{ github.event.release.tag_name }} + elif [[ ${{ github.event_name == 'workflow_run' }} == true ]]; then + CTVER=$(cat ${{ runner.temp }}/artifacts/testinfo.txt | grep CTVER | cut -d'=' -f2) + else + CTVER="latest" + fi + curl -L \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.TESTSUITE_REPOSITORY_ACCESS_TOKEN }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/ICICLE-ai/ml_workbench_test_suite/dispatches \ + -d '{"event_type":"dispatch-event", "client_payload": {"ct_version": "'"${CTVER}"'"}}'