Skip to content

improve Fdetail info in ssnew for Fmethod 4 #387

improve Fdetail info in ssnew for Fmethod 4

improve Fdetail info in ssnew for Fmethod 4 #387

# Build stock synthesis on linux with all c++ compiler warnings, and fail job if the
# number of warnings has increased using the warnings_ss_ref.txt file under
# workflows > reference_files.
# Only runs on a pull request and a push to main if the tpl files have changed
name: build-ss3-warnings
# Controls when the action will run.
on:
workflow_dispatch:
push:
paths:
- '**.tpl'
branches:
- main
pull_request:
types: ['opened', 'edited', 'reopened', 'synchronize', 'ready_for_review']
paths:
- '**.tpl'
branches:
- main
jobs:
build-warnings:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"
steps:
- name: Checkout ss3 repo
uses: actions/checkout@v4
- name: Update Ubuntu packages
run: sudo apt-get update
- name: Setup R
uses: r-lib/actions/setup-r@v2
# - name: Get admb and put in path, linux
# run: |
# wget https://github.com/admb-project/admb/releases/download/admb-13.1/admb-13.1-linux.zip
# sudo unzip admb-13.1-linux.zip -d /usr/local/bin
# sudo chmod 755 /usr/local/bin/admb-13.1/bin/admb
# echo "/usr/local/bin/admb-13.1/bin" >> $GITHUB_PATH
- name: Build stock synthesis with warnings using admb docker image and display in console
run: |
rm -rf SS330
rm -rf ss3_osx.tar
mkdir SS330
chmod 777 SS330
/bin/bash ./Make_SS_330_new.sh --admb docker -b SS330 -w
- name: Build stock synthesis with warnings using admb docker image again to save to file
run: |
rm -rf SS330
rm -rf ss3_osx.tar
mkdir SS330
chmod 777 SS330
/bin/bash ./Make_SS_330_new.sh --admb docker -b SS330 -w &> warnings.txt
# Runs a set of commands using the runners shell
- name: Use R to parse warnings output
run: |
txt <- readLines("warnings.txt", encoding = "UTF-8")
warn_line <- grep(pattern = "g++ -c -std=c++17 -O3 -Wall -Wextra -D_USE_MATH_DEFINES -DUSE_ADMB_CONTRIBS", x = txt, fixed = TRUE)
end_warn_line <- grep(pattern = "*** Linking: ss3.obj ", x = txt, fixed = TRUE)
if (length(warn_line) == 1 & length(end_warn_line) == 1) {
txt <- txt[(warn_line+3):(end_warn_line-1)]
rm_warn_start_lines <- grep(pattern = "/usr/local/admb/include/admodel.h: ", x = txt, fixed = TRUE, invert = TRUE)
txt <- txt[rm_warn_start_lines]
n_errors <- length(grep(pattern = "^ [0-9]", x = txt))
message("There are ", n_errors, " warning messages related to SS3.")
write.table(n_errors, "n_warn.txt")
}
writeLines(txt, "warnings_ss.txt")
# warn_line <- grep(pattern = "compiling a second time to get warnings", x = txt, fixed = TRUE)
# txt <- txt[(warn_line+1):length(txt)]
shell: Rscript {0}
- name: Print warnings
run: cat warnings_ss.txt
- name: Determine if fails/passes based on the number of warnings
run: |
ref <- readLines(".github/workflows/reference_files/warnings_ss_ref.txt")
n_warn <- read.table("n_warn.txt")
n_warn <- as.integer(n_warn[1,1])
if (n_warn > length(ref)) {
stop("Increased number of warnings compared to reference warning file")
} else {
# n_warn doesn't take into account the "In file included from ss.cpp:7:"
# so add 2 to add those lines back in
if (n_warn+length(ref) < length(ref)){
stop("Number of warnings of decreased compared to reference warning file")
} else {
message("Acceptable number of warnings")
}
}
shell: Rscript {0}
- name: Archive warnings text file
if: always()
uses: actions/upload-artifact@main
with:
name: 'warnings_ss.txt'
path: warnings_ss.txt