Skip to content

Commit 9d16add

Browse files
author
e-perl-NOAA
committed
Fix test simple with ss3 artifacts, remove add artifacts workflow since it isn't working and I can't get any variation of it to work; have build-ss3 be on PR too so it correctly triggers test simple with ss3-artifacts
1 parent 9523b83 commit 9d16add

3 files changed

Lines changed: 74 additions & 107 deletions

File tree

.github/workflows/add-exe-build-artifacts-to-PR.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

.github/workflows/build-ss3.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ on:
88
paths:
99
- '**.tpl'
1010
- '**.sh'
11+
pull_request:
12+
paths:
13+
- '**.tpl'
14+
- '**.sh'
1115
workflow_dispatch:
1216

1317
concurrency:
Lines changed: 70 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,120 +1,103 @@
11
name: test-simple-with-ss3-artifacts
2+
23
on:
34
workflow_run:
45
workflows: ["build-ss3"]
56
types:
67
- completed
7-
workflow_dispatch:
8-
9-
permissions:
10-
contents: read
11-
actions: read
12-
13-
concurrency:
14-
group: ${{ github.workflow }}-${{ github.ref }}
15-
cancel-in-progress: true
168

179
jobs:
18-
test-simple-model:
19-
if: ${{ github.event.workflow_run.conclusion == 'success' }}
10+
find_build_artifacts:
11+
runs-on: ubuntu-latest # A general runner to get the run ID
12+
outputs:
13+
run_id: ${{ steps.get_run_id.outputs.run_id }}
14+
parent_workflow_event: ${{ github.event.workflow_run.event }}
15+
steps:
16+
- name: Get workflow_run ID and Parent Event
17+
id: get_run_id
18+
run: |
19+
echo "Run ID of build-ss3 workflow: ${{ github.event.workflow_run.id }}"
20+
echo "run_id=${{ github.event.workflow_run.id }}" >> "$GITHUB_OUTPUT"
21+
echo "Parent workflow event: ${{ github.event.workflow_run.event }}"
22+
echo "parent_workflow_event=${{ github.event.workflow_run.event }}" >> "$GITHUB_OUTPUT"
23+
24+
test_builds:
25+
needs: find_build_artifacts
26+
if: needs.find_build_artifacts.outputs.parent_workflow_event == 'pull_request'
27+
2028
runs-on: ${{ matrix.os }}
2129
strategy:
2230
matrix:
23-
os: [ubuntu-latest, windows-latest, macos-13, macos-latest]
31+
os: [ubuntu-latest, macos-13, macos-latest, windows-latest]
2432
include:
2533
- os: ubuntu-latest
2634
artifact_name: ss3-ubuntu-latest
27-
exe_name: ss3_linux
28-
- os: windows-latest
29-
artifact_name: ss3-windows-latest
30-
exe_name: ss3_win.exe
35+
exe: ss3_linux
3136
- os: macos-13
3237
artifact_name: ss3-macos-13
33-
exe_name: ss3_osx
38+
exe: ss3_osx
3439
- os: macos-latest
3540
artifact_name: ss3-macos-latest
36-
exe_name: ss3_osx
41+
exe: ss3_osx
42+
- os: windows-latest
43+
artifact_name: ss3-windows-latest
44+
exe: ss3_win.exe
3745

3846
steps:
39-
- name: Checkout test repo (this repo)
40-
uses: actions/checkout@v5
41-
42-
- name: Set up jq and unzip (Linux/macOS)
43-
if: runner.os != 'Windows'
44-
run: |
45-
sudo apt-get update || true
46-
sudo apt-get install -y jq unzip || brew install jq unzip
47-
48-
- name: Set up jq (Windows)
49-
if: runner.os == 'Windows'
50-
run: choco install jq
51-
52-
- name: Use Bash 5 on macOS
53-
if: startsWith(matrix.os, 'macos-')
54-
run: brew install bash
55-
56-
- name: List all artifacts for workflow run
57-
uses: actions/github-script@v7
58-
with:
59-
github-token: ${{ secrets.GITHUB_TOKEN }}
60-
script: |
61-
const run_id = ${{ github.event.workflow_run.id }};
62-
const { data: artifacts } = await github.rest.actions.listWorkflowRunArtifacts({
63-
owner: "nmfs-ost",
64-
repo: "ss3-source-code",
65-
run_id
66-
});
67-
console.log(artifacts.artifacts);
68-
69-
- name: Download artifact for this OS
70-
uses: actions/download-artifact@v4
71-
with:
72-
name: ${{ matrix.artifact_name }}
73-
run-id: ${{ github.event.workflow_run.id }}
74-
repository: nmfs-ost/ss3-source-code
75-
path: ss3_artifacts
76-
77-
- name: Unzip SS3 executable
78-
shell: bash
79-
run: |
80-
cd ss3_artifacts
81-
if [ "${{ runner.os }}" = "Windows" ]; then
82-
powershell -Command "Expand-Archive -Path '${{ matrix.artifact_name }}.zip' -DestinationPath ."
83-
else
84-
unzip -o "${{ matrix.artifact_name }}.zip"
85-
fi
86-
87-
- name: Checkout test models repository
47+
- name: Checkout SS3 Test Models
8848
uses: actions/checkout@v5
8949
with:
9050
repository: nmfs-ost/ss3-test-models
9151
path: ss3-test-models
9252

93-
- name: Ensure Simple model directory exists
94-
shell: bash
95-
run: mkdir -p ss3-test-models/models/Simple
96-
97-
- name: see what files exist
98-
shell: bash
53+
- name: Download ${{ matrix.artifact_name }} artifact
54+
uses: actions/github-script@v6
55+
with:
56+
script: |
57+
const { owner, repo } = context.repo;
58+
const run_id = '${{ needs.find_build_artifacts.outputs.run_id }}';
59+
const artifactName = '${{ matrix.artifact_name }}';
60+
console.log(`Attempting to download artifact '${artifactName}' from run ID: ${run_id}`);
61+
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
62+
owner,
63+
repo,
64+
run_id: run_id,
65+
});
66+
const artifact = artifacts.data.artifacts.find(artifact => artifact.name === artifactName);
67+
if (artifact) {
68+
const download = await github.rest.actions.downloadArtifact({
69+
owner,
70+
repo,
71+
artifact_id: artifact.id,
72+
archive_format: 'zip',
73+
});
74+
const fs = require('fs');
75+
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/${artifactName}.zip`, Buffer.from(download.data));
76+
console.log(`Artifact ${artifactName}.zip downloaded successfully.`);
77+
} else {
78+
core.setFailed(`Artifact ${artifactName} not found. Please ensure the artifact name matches exactly.`);
79+
}
80+
81+
- name: Unzip artifact and set permissions
82+
if: runner.os == 'Windows'
83+
shell: pwsh
9984
run: |
100-
echo "Files in ss3_artifacts:"
101-
find ss3_artifacts
102-
103-
- name: Copy SS3 executable to Simple model directory
85+
Expand-Archive -Path "${{ github.workspace }}\${{ matrix.artifact_name }}.zip" -DestinationPath "ss3-test-models/models/Simple" -Force
86+
87+
- name: Unzip artifact and set permissions
88+
if: ${{ runner.os != 'Windows' }}
10489
shell: bash
10590
run: |
106-
exe="${{ matrix.exe_name }}"
107-
src="ss3_artifacts/$exe"
108-
dest="ss3-test-models/models/Simple/$exe"
109-
cp "$src" "$dest"
110-
chmod +x "$dest" || true
111-
91+
unzip ${{ matrix.artifact_name }}.zip -d ss3-test-models/models/Simple
92+
# Make executables runnable on Linux/macOS
93+
chmod +x ss3-test-models/models/Simple/${{ matrix.exe }}
94+
11295
- name: Run SS3 on Simple model
11396
shell: bash
11497
run: |
11598
cd ss3-test-models/models/Simple
116-
./${{ matrix.exe_name }} -nohess -stopph 0
117-
99+
./${{ matrix.exe }} -nohess -stopph 0
100+
118101
- name: Check if model ran successfully
119102
shell: bash
120103
run: |
@@ -127,4 +110,5 @@ jobs:
127110
uses: actions/upload-artifact@v4
128111
with:
129112
name: simple-model-output-${{ matrix.os }}
130-
path: ss3-test-models/models/Simple/
113+
path: ss3-test-models/models/Simple/
114+

0 commit comments

Comments
 (0)