test-simple-with-ss3-artifacts #146
This file contains hidden or 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: test-simple-with-ss3-artifacts | |
| on: | |
| workflow_run: | |
| workflows: ["build-ss3"] | |
| types: | |
| - completed | |
| jobs: | |
| find_build_artifacts: | |
| runs-on: ubuntu-latest # A general runner to get the run ID | |
| outputs: | |
| run_id: ${{ steps.get_run_id.outputs.run_id }} | |
| parent_workflow_event: ${{ github.event.workflow_run.event }} | |
| steps: | |
| - name: Get workflow_run ID and Parent Event | |
| id: get_run_id | |
| run: | | |
| echo "Run ID of build-ss3 workflow: ${{ github.event.workflow_run.id }}" | |
| echo "run_id=${{ github.event.workflow_run.id }}" >> "$GITHUB_OUTPUT" | |
| echo "Parent workflow event: ${{ github.event.workflow_run.event }}" | |
| echo "parent_workflow_event=${{ github.event.workflow_run.event }}" >> "$GITHUB_OUTPUT" | |
| test_builds: | |
| needs: find_build_artifacts | |
| if: needs.find_build_artifacts.outputs.parent_workflow_event == 'pull_request' | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, macos-15-intel, macos-latest, windows-latest] | |
| include: | |
| - os: ubuntu-latest | |
| artifact_name: ss3-ubuntu-latest | |
| exe: ss3_linux | |
| - os: macos-15-intel | |
| artifact_name: ss3-macos-15-intel | |
| exe: ss3_osx | |
| - os: macos-latest | |
| artifact_name: ss3-macos-latest | |
| exe: ss3_osx | |
| - os: windows-latest | |
| artifact_name: ss3-windows-latest | |
| exe: ss3_win.exe | |
| steps: | |
| - name: Checkout SS3 Test Models | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: nmfs-ost/ss3-test-models | |
| path: ss3-test-models | |
| - name: Download ${{ matrix.artifact_name }} artifact | |
| uses: actions/github-script@v8 | |
| with: | |
| script: | | |
| const { owner, repo } = context.repo; | |
| const run_id = '${{ needs.find_build_artifacts.outputs.run_id }}'; | |
| const artifactName = '${{ matrix.artifact_name }}'; | |
| console.log(`Attempting to download artifact '${artifactName}' from run ID: ${run_id}`); | |
| const artifacts = await github.rest.actions.listWorkflowRunArtifacts({ | |
| owner, | |
| repo, | |
| run_id: run_id, | |
| }); | |
| const artifact = artifacts.data.artifacts.find(artifact => artifact.name === artifactName); | |
| if (artifact) { | |
| const download = await github.rest.actions.downloadArtifact({ | |
| owner, | |
| repo, | |
| artifact_id: artifact.id, | |
| archive_format: 'zip', | |
| }); | |
| const fs = require('fs'); | |
| fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/${artifactName}.zip`, Buffer.from(download.data)); | |
| console.log(`Artifact ${artifactName}.zip downloaded successfully.`); | |
| } else { | |
| core.setFailed(`Artifact ${artifactName} not found. Please ensure the artifact name matches exactly.`); | |
| } | |
| - name: Unzip artifact and set permissions | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| Expand-Archive -Path "${{ github.workspace }}\${{ matrix.artifact_name }}.zip" -DestinationPath "ss3-test-models/models/Simple" -Force | |
| - name: Unzip artifact and set permissions | |
| if: ${{ runner.os != 'Windows' }} | |
| shell: bash | |
| run: | | |
| unzip ${{ matrix.artifact_name }}.zip -d ss3-test-models/models/Simple | |
| # Make executables runnable on Linux/macOS | |
| chmod +x ss3-test-models/models/Simple/${{ matrix.exe }} | |
| - name: Run SS3 on Simple model | |
| shell: bash | |
| run: | | |
| cd ss3-test-models/models/Simple | |
| ./${{ matrix.exe }} -nohess -stopph 0 | |
| - name: Check if model ran successfully | |
| shell: bash | |
| run: | | |
| if [ ! -f "ss3-test-models/models/Simple/control.ss_new" ]; then | |
| echo "ERROR: control.ss_new not found!" | |
| exit 1 | |
| fi | |
| - name: Archive Simple model output | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: simple-model-output-${{ matrix.os }} | |
| path: ss3-test-models/models/Simple/ | |