diff --git a/.github/workflows/build-ss3-warnings.yml b/.github/workflows/build-ss3-warnings.yml index 7bd21116..945ef67c 100644 --- a/.github/workflows/build-ss3-warnings.yml +++ b/.github/workflows/build-ss3-warnings.yml @@ -19,6 +19,10 @@ on: branches: - main +concurrency: + group: ${{ github.workflow}}-${{ github.ref }} + cancel-in-progress: true + jobs: build-warnings: if: github.event.pull_request.draft == false diff --git a/.github/workflows/build-ss3.yml b/.github/workflows/build-ss3.yml index 7418bae5..655a9a46 100644 --- a/.github/workflows/build-ss3.yml +++ b/.github/workflows/build-ss3.yml @@ -10,7 +10,10 @@ on: - '**.sh' workflow_dispatch: - +concurrency: + group: ${{ github.workflow}}-${{ github.ref }} + cancel-in-progress: true + jobs: build-ss3: runs-on: ${{ matrix.config.os }} diff --git a/.github/workflows/run-ss3-bootstrap.yml b/.github/workflows/run-ss3-bootstrap.yml index af3fd92d..aa1e8910 100644 --- a/.github/workflows/run-ss3-bootstrap.yml +++ b/.github/workflows/run-ss3-bootstrap.yml @@ -17,6 +17,10 @@ on: branches: - main +concurrency: + group: ${{ github.workflow}}-${{ github.ref }} + cancel-in-progress: true + jobs: run-ss3-bootstrap-files: if: github.event.pull_request.draft == false diff --git a/.github/workflows/run-ss3-mcmc.yml b/.github/workflows/run-ss3-mcmc.yml index 29b29df5..8ec627bf 100644 --- a/.github/workflows/run-ss3-mcmc.yml +++ b/.github/workflows/run-ss3-mcmc.yml @@ -15,7 +15,11 @@ on: - '**.tpl' branches: - main - + +concurrency: + group: ${{ github.workflow}}-${{ github.ref }} + cancel-in-progress: true + # Check MCMC works jobs: run-ss3-no-est: diff --git a/.github/workflows/run-ss3-no-est.yml b/.github/workflows/run-ss3-no-est.yml index ccd0e537..b8d18e54 100644 --- a/.github/workflows/run-ss3-no-est.yml +++ b/.github/workflows/run-ss3-no-est.yml @@ -14,6 +14,10 @@ on: branches: - main +concurrency: + group: ${{ github.workflow}}-${{ github.ref }} + cancel-in-progress: true + # Run models without estimation, then try to run again with .ss_new jobs: run-ss3-no-est: diff --git a/.github/workflows/run-ss3-with-est.yml b/.github/workflows/run-ss3-with-est.yml index 2225df50..f3611431 100644 --- a/.github/workflows/run-ss3-with-est.yml +++ b/.github/workflows/run-ss3-with-est.yml @@ -17,6 +17,10 @@ on: branches: - main +concurrency: + group: ${{ github.workflow}}-${{ github.ref }} + cancel-in-progress: true + # Run fast running SS3 test models with estimation jobs: run-ss3-with-est: diff --git a/.github/workflows/test-r4ss-with-ss3.yml b/.github/workflows/test-r4ss-with-ss3.yml index e1d9e618..e24f4475 100644 --- a/.github/workflows/test-r4ss-with-ss3.yml +++ b/.github/workflows/test-r4ss-with-ss3.yml @@ -16,6 +16,10 @@ on: branches: - main +concurrency: + group: ${{ github.workflow}}-${{ github.ref }} + cancel-in-progress: true + # Run models without estimation, then run r4ss SS_plots() and SS_output() jobs: test-r4ss-with-ss3: diff --git a/.github/workflows/test-simple-with-ss3-artifacts.yml b/.github/workflows/test-simple-with-ss3-artifacts.yml new file mode 100644 index 00000000..4399d23f --- /dev/null +++ b/.github/workflows/test-simple-with-ss3-artifacts.yml @@ -0,0 +1,191 @@ +on: + workflow_run: + workflows: ["build-ss3"] + types: + - completed + workflow_dispatch: + +permissions: + contents: read + actions: read + +concurrency: + group: ${{ github.workflow}}-${{ github.ref }} + cancel-in-progress: true + +jobs: + test-simple-model: + if: ${{ github.event.workflow_run.conclusion == 'success' }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-13, macos-latest] + include: + - os: ubuntu-latest + artifact_name: ss3-ubuntu-latest + exe_name: ss3_linux + - os: windows-latest + artifact_name: ss3-windows-latest + exe_name: ss3_win.exe + - os: macos-13 + artifact_name: ss3-macos-13 + exe_name: ss3_osx + - os: macos-latest + artifact_name: ss3-macos-latest + exe_name: ss3_osx + + steps: + - name: Checkout test repo (this repo) + uses: actions/checkout@v4 + + - name: Set up jq and unzip (Linux/macOS) + if: runner.os != 'Windows' + run: | + sudo apt-get update || true + sudo apt-get install -y jq unzip || brew install jq unzip + + - name: Set up jq (Windows) + if: runner.os == 'Windows' + run: choco install jq + + - name: Use Bash 5 on macOS + if: startsWith(matrix.os, 'macos-') + run: brew install bash + + - name: Find latest successful build-ss3 workflow run in nmfs-ost/ss3-source-code + id: get_run + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const { data: workflows } = await github.rest.actions.listRepoWorkflows({ + owner: "nmfs-ost", + repo: "ss3-source-code" + }); + const workflow = workflows.workflows.find(wf => wf.name === "build-ss3"); + if (!workflow) throw "Workflow 'build-ss3' not found."; + const { data: runs } = await github.rest.actions.listWorkflowRuns({ + owner: "nmfs-ost", + repo: "ss3-source-code", + workflow_id: workflow.id, + status: "success", + per_page: 1 + }); + if (!runs.workflow_runs.length) throw "No successful runs found for 'build-ss3'."; + core.setOutput("run_id", runs.workflow_runs[0].id); + + - name: List artifacts from build-ss3 run + id: list_artifacts + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const run_id = ${{ steps.get_run.outputs.run_id }}; + const { data: artifacts } = await github.rest.actions.listWorkflowRunArtifacts({ + owner: "nmfs-ost", + repo: "ss3-source-code", + run_id + }); + core.setOutput("artifacts", JSON.stringify(artifacts.artifacts)); + + - name: Download artifact for this OS + id: download_artifact + shell: bash + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -e + mkdir -p ss3_artifacts + os_artifact="${{ matrix.artifact_name }}" + ARTIFACTS_JSON='${{ steps.list_artifacts.outputs.artifacts }}' + ARTIFACTS_JSON=$(echo "$ARTIFACTS_JSON" | tr -d '\r') + echo "RAW ARTIFACTS OUTPUT:" + echo "$ARTIFACTS_JSON" | cat -v + + IFS=$'\n' artifacts=($(echo "$ARTIFACTS_JSON" | jq -cr '.[] | select(. != null) | @base64' | tr -d '\r' | grep -v '^$')) + if [[ ${#artifacts[@]} -eq 0 ]]; then + echo "No artifacts found." + exit 1 + fi + + echo "Available artifacts:" + for artifact in "${artifacts[@]}"; do + echo "${artifact}" | base64 --decode | jq -r '.name' + done + + found_id="" + for artifact in "${artifacts[@]}"; do + _jq() { + echo "${artifact}" | base64 --decode | jq -r "${1}" + } + name=$(_jq '.name') + id=$(_jq '.id') + if [[ "$name" == "$os_artifact" ]]; then + found_id="$id" + break + fi + done + if [ -z "$found_id" ]; then + echo "Artifact $os_artifact not found!" + exit 1 + fi + echo "Downloading artifact: $os_artifact" + gh api \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $GH_TOKEN" \ + "./repos/nmfs-ost/ss3-source-code/actions/artifacts/$found_id/zip" > "ss3_artifacts/$os_artifact.zip" + + - name: Unzip SS3 executable + shell: bash + run: | + cd ss3_artifacts + if [ "${{ runner.os }}" = "Windows" ]; then + powershell -Command "Expand-Archive -Path '${{ matrix.artifact_name }}.zip' -DestinationPath ." + else + unzip -o "${{ matrix.artifact_name }}.zip" + fi + + - name: Checkout test models repository + uses: actions/checkout@v4 + with: + repository: nmfs-ost/ss3-test-models + path: ss3-test-models + + - name: Ensure Simple model directory exists + shell: bash + run: mkdir -p ss3-test-models/models/Simple + + - name: see what files exist + shell: bash + run: | + echo "Files in ss3_artifacts:" + find ss3_artifacts + + - name: Copy SS3 executable to Simple model directory + shell: bash + run: | + exe="${{ matrix.exe_name }}" + src="ss3_artifacts/$exe" + dest="ss3-test-models/models/Simple/$exe" + cp "$src" "$dest" + chmod +x "$dest" || true + + - name: Run SS3 on Simple model + shell: bash + run: | + cd ss3-test-models/models/Simple + ./${{ matrix.exe_name }} -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@v4 + with: + name: simple-model-output-${{ matrix.os }} + path: ss3-test-models/models/Simple/ \ No newline at end of file diff --git a/Make_SS_330_new.sh b/Make_SS_330_new.sh index ae2743b7..d4d0b358 100755 --- a/Make_SS_330_new.sh +++ b/Make_SS_330_new.sh @@ -19,8 +19,9 @@ function usage() echo "" echo "Call this script as follows:" echo " ./Make_SS_330_new.sh [(-s | --source) source_dir] [(-b | --build) build_dir]" - echo " [(-a | --admb) admb_dir] [[-o | --opt] | [-f | --safe] [-p] " + echo " [(-a | --admb) admb_dir] [[-o | --opt] | [-f | --safe] [-p]" echo " [-w | --warn] [-d | --debug] [-h | --help]" + # build statically (full static) echo "Notes:" echo " -p is an ADMB flag to build statically and will be passed. " echo " -w re-compiles with common warnings enabled. " @@ -175,28 +176,31 @@ if [[ "$ADMB_HOME" == "docker" ]] ; then fi if [[ "$WARNINGS" == "on" ]] ; then if [[ "$WINDOWS10" == "true" ]] ; then - docker run --env CXXFLAGS="-Wall -Wextra" --rm --mount source=`cygpath -w $PWD`\\$BUILD_DIR,destination=C:\\$BUILD_TYPE,mount=bind --workdir C:\\$BUILD_TYPE johnoel/admb-13.2:windows10 $BUILD_TYPE.tpl + docker run --env CXXFLAGS="-Wall -Wextra" --rm --mount source=`cygpath -w $PWD`\\$BUILD_DIR,destination=C:\\$BUILD_TYPE,mount=bind --workdir C:\\$BUILD_TYPE johnoel/admb-13.2:windows10 $OPTFLAG $STATICFLAG $BUILD_TYPE.tpl else - docker run --env CXXFLAGS="-Wall -Wextra" --rm --mount source=`cygpath -w $PWD`\\$BUILD_DIR,destination=C:\\$BUILD_TYPE,mount=bind --workdir C:\\$BUILD_TYPE johnoel/admb-13.2:windows $BUILD_TYPE.tpl + docker run --env CXXFLAGS="-Wall -Wextra" --rm --mount source=`cygpath -w $PWD`\\$BUILD_DIR,destination=C:\\$BUILD_TYPE,mount=bind --workdir C:\\$BUILD_TYPE johnoel/admb-13.2:windows $OPTFLAG $STATICFLAG $BUILD_TYPE.tpl fi else if [[ "$WINDOWS10" == "true" ]] ; then - docker run --rm --mount source=`cygpath -w $PWD`\\$BUILD_DIR,destination=C:\\$BUILD_TYPE,mount=bind --workdir C:\\$BUILD_TYPE johnoel/admb-13.2:windows10 $BUILD_TYPE.tpl + docker run --rm --mount source=`cygpath -w $PWD`\\$BUILD_DIR,destination=C:\\$BUILD_TYPE,mount=bind --workdir C:\\$BUILD_TYPE johnoel/admb-13.2:windows10 $OPTFLAG $STATICFLAG $BUILD_TYPE.tpl else - docker run --rm --mount source=`cygpath -w $PWD`\\$BUILD_DIR,destination=C:\\$BUILD_TYPE,mount=bind --workdir C:\\$BUILD_TYPE johnoel/admb-13.2:windows $BUILD_TYPE.tpl + docker run --rm --mount source=`cygpath -w $PWD`\\$BUILD_DIR,destination=C:\\$BUILD_TYPE,mount=bind --workdir C:\\$BUILD_TYPE johnoel/admb-13.2:windows $OPTFLAG $STATICFLAG $BUILD_TYPE.tpl fi fi else if [[ "$WARNINGS" == "on" ]] ; then - docker run --env CXXFLAGS="-Wall -Wextra" --rm --mount source=$PWD/$BUILD_DIR,destination=/$BUILD_TYPE,type=bind --workdir /$BUILD_TYPE johnoel/admb-13.2:linux $BUILD_TYPE.tpl + export CXXFLAGS="-Wall -Wextra -static-libstdc++ -static-libgcc" else - docker run --rm --mount source=$PWD/$BUILD_DIR,destination=/$BUILD_TYPE,type=bind --workdir /$BUILD_TYPE johnoel/admb-13.2:linux $BUILD_TYPE.tpl + export CXXFLAGS="-static-libstdc++ -static-libgcc" fi + docker run --env CXXFLAGS="$CXXFLAGS" --rm --mount source=$PWD/$BUILD_DIR,destination=/$BUILD_TYPE,type=bind --workdir /$BUILD_TYPE johnoel/admb-13.2:linux $OPTFLAG $STATICFLAG $BUILD_TYPE.tpl fi else command pushd $BUILD_DIR > /dev/null if [[ "$WARNINGS" == "on" ]] ; then - export CXXFLAGS="-Wall -Wextra" + export CXXFLAGS="-Wall -Wextra -static-libstdc++ -static-libgcc" + else + export CXXFLAGS="-static-libstdc++ -static-libgcc" fi if [[ "$OS" == "Windows_NT" ]] ; then admb.sh $OPTFLAG $STATICFLAG $BUILD_TYPE