Skip to content

Commit

Permalink
Update & cleanup workflows
Browse files Browse the repository at this point in the history
Allow manual triggering of tests
  • Loading branch information
shBLOCK committed May 7, 2024
1 parent 336b645 commit 587b9a9
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 36 deletions.
12 changes: 3 additions & 9 deletions .github/workflows/codegen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.12

Expand All @@ -28,15 +28,9 @@ jobs:
run: python gen_all.py
working-directory: codegen

# - name: Copy outputs to src
# run: copy "codegen\output\*" "src\gdmath"

# - name: Validate
# run: pip install .

- name: Upload Artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: codegen_results
path: codegen/output/
retention-days: 5
retention-days: 10
16 changes: 8 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.12

Expand All @@ -43,7 +43,7 @@ jobs:
run: copy "codegen\output\*" "src\spatium"

- name: Upload Artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: codegen_results
path: codegen/output/
Expand All @@ -60,13 +60,13 @@ jobs:
uses: actions/checkout@v4

- name: Download Codegen Output
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: codegen_results
path: src/spatium

- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.12

Expand All @@ -84,7 +84,7 @@ jobs:
}
- name: Upload to Artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: dists
path: dist/
Expand All @@ -102,7 +102,7 @@ jobs:
uses: actions/checkout@v4

- name: Download Codegen Output
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: codegen_results
path: src/spatium
Expand All @@ -122,7 +122,7 @@ jobs:
# }

- name: Upload to Artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: dists
path: dist/
Expand All @@ -149,7 +149,7 @@ jobs:
- run: mkdir dist

- name: Download Artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: dists
path: dist
Expand Down
77 changes: 58 additions & 19 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
workflow_run:
workflows: [Codegen]
types: [completed]
workflow_dispatch:

jobs:
tests:
Expand All @@ -19,32 +20,70 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Download Codegen Output
uses: actions/github-script@v6
- name: Fetch Latest Codegen Result
uses: actions/github-script@v7
with:
# noinspection TypeScriptUnresolvedReference
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 == "codegen_results"
})[0];
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/codegen_results.zip`, Buffer.from(download.data));
let runs = await github.rest.actions.listWorkflowRuns({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: "codegen.yml"
})
let latest = runs.data.workflow_runs.sort(run => -run.run_number)[0]
let artifact = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: latest.id,
}).data.artifacts.filter((artifact) => {
return artifact.name == "codegen_results"
})[0];
if (artifact.expired) {
core.setFailed("Codegen artifact expired, please manually run the codegen workflow to generate a new result.");
} else {
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/codegen_results.zip`, Buffer.from(download.data));
}
# - name: Download Codegen Output
# uses: actions/download-artifact@v4
# with:
# name: codegen_results
# github-token: ${{ github.token }}
# run-id: ${{ github }}
#
# - name: Download Codegen Output
# 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 == "codegen_results"
# })[0];
# let download = await github.rest.actions.downloadArtifact({
# owner: context.repo.owner,
# repo: context.repo.repo,
# artifact_id: matchArtifact.id,
# archive_format: 'zip',
# });
# let fs = require('fs');
# fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/codegen_results.zip`, Buffer.from(download.data));

- name: Unzip
run: 7z x codegen_results.zip -osrc/spatium

- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}

Expand Down

0 comments on commit 587b9a9

Please sign in to comment.