Skip to content

Commit b08410c

Browse files
committed
Review actions and workflows for best practices and consistency
1 parent 0f684ef commit b08410c

File tree

8 files changed

+141
-131
lines changed

8 files changed

+141
-131
lines changed

.github/workflows/run-experiment.yaml

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,25 @@ jobs:
1919
uses: danielvartan/logoactions/setup-netlogo@v1
2020

2121
- name: Create artifacts directory
22+
id: artifacts-dir
2223
run: |
2324
# Create artifacts directory
2425
25-
mkdir -p '/tmp/artifacts'
26+
artifacts_dir="${RUNNER_TEMP}/artifacts"
27+
mkdir -p "${artifacts_dir}"
28+
29+
echo "path=${artifacts_dir}" >> "${GITHUB_OUTPUT}"
2630
shell: bash
2731

2832
- name: Run experiment 1
2933
run: |
3034
# Run experiment 1
3135
32-
model_dir="$NETLOGO_HOME/models/Sample Models/Biology"
36+
artifacts_dir="${{ steps.artifacts-dir.outputs.path }}"
37+
model_dir="${NETLOGO_HOME}/models/Sample Models/Biology"
3338
model_file='Wolf Sheep Predation.nlogox'
3439
experiment_name='Wolf Sheep Crossing'
35-
table_file='/tmp/artifacts/experiment-1-table.csv'
40+
table_file="${artifacts_dir}/experiment-1-table.csv"
3641
3742
netlogo \
3843
--headless \
@@ -47,10 +52,11 @@ jobs:
4752
run: |
4853
# Run experiment 2
4954
50-
model_dir="$NETLOGO_HOME/models/Curricular Models/GenEvo"
55+
artifacts_dir="${{ steps.artifacts-dir.outputs.path }}"
56+
model_dir="${NETLOGO_HOME}/models/Curricular Models/GenEvo"
5157
model_file='Synthetic Biology - Genetic Switch.nlogox'
5258
experiment_name='Sample-Experiment'
53-
table_file='/tmp/artifacts/experiment-2-table.csv'
59+
table_file="${artifacts_dir}/experiment-2-table.csv"
5460
5561
netlogo \
5662
--headless \
@@ -65,10 +71,11 @@ jobs:
6571
run: |
6672
# Run experiment 3
6773
68-
model_dir="$NETLOGO_HOME/models/IABM Textbook/chapter 6"
74+
artifacts_dir="${{ steps.artifacts-dir.outputs.path }}"
75+
model_dir="${NETLOGO_HOME}/models/IABM Textbook/chapter 6"
6976
model_file='Spread of Disease.nlogox'
7077
experiment_name='population-density'
71-
table_file='/tmp/artifacts/experiment-3-table.csv'
78+
table_file="${artifacts_dir}/experiment-3-table.csv"
7279
7380
netlogo \
7481
--headless \
@@ -83,28 +90,30 @@ jobs:
8390
run: |
8491
# Run experiment 4
8592
86-
model_dir="$NETLOGO_HOME/models/IABM Textbook/chapter 7"
93+
artifacts_dir="${{ steps.artifacts-dir.outputs.path }}"
94+
model_dir="${NETLOGO_HOME}/models/IABM Textbook/chapter 7"
8795
model_file='Voting Sensitivity Analysis.nlogox'
8896
experiment_name='sensitivity-experiment'
89-
table_file='/tmp/artifacts/experiment-4-table.csv'
97+
table_file="${artifacts_dir}/experiment-4-table.csv"
9098
9199
netlogo \
92100
--headless \
93-
--model "$model_dir/$model_file" \
94-
--experiment "$experiment_name" \
95-
--table "$table_file"
101+
--model "${model_dir}/${model_file}" \
102+
--experiment "${experiment_name}" \
103+
--table "${table_file}"
96104
97-
cat "$table_file"
105+
cat "${table_file}"
98106
shell: bash
99107

100108
- name: Run experiment 5
101109
run: |
102110
# Run experiment 5
103111
104-
model_dir="$NETLOGO_HOME/models/Curricular Models/BEAGLE Evolution"
112+
artifacts_dir="${{ steps.artifacts-dir.outputs.path }}"
113+
model_dir="${NETLOGO_HOME}/models/Curricular Models/BEAGLE Evolution"
105114
model_file='Red Queen.nlogox'
106115
experiment_name='Final Counts'
107-
table_file='/tmp/artifacts/experiment-5-table.csv'
116+
table_file="${artifacts_dir}/experiment-5-table.csv"
108117
109118
netlogo \
110119
--headless \
@@ -119,5 +128,5 @@ jobs:
119128
uses: actions/upload-artifact@v4
120129
with:
121130
name: experiments-output
122-
path: '/tmp/artifacts/'
131+
path: ${{ steps.artifacts-dir.outputs.path }}
123132
retention-days: 90

.github/workflows/run-logolink.yaml

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
name: Run experiments with Quarto and logolink
1111
runs-on: ubuntu-latest
1212
env:
13-
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
13+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1414
permissions:
1515
contents: write
1616
pages: write
@@ -28,6 +28,7 @@ jobs:
2828
uses: quarto-dev/quarto-actions/setup@v2
2929

3030
- name: Install system dependencies
31+
if: runner.os == 'Linux'
3132
run: |
3233
# Install system dependencies
3334
@@ -74,28 +75,14 @@ jobs:
7475
run: |
7576
# Install and initialize renv
7677
78+
options(repos=c(CRAN="https://cloud.r-project.org"))
79+
7780
install.packages("renv")
7881
7982
renv::init()
8083
shell: Rscript {0}
8184
working-directory: './tests/qmd'
8285

83-
- name: Install logolink development version
84-
if: steps.renv-check.outputs.exists == 'false'
85-
run: |
86-
# Install logolink development version
87-
88-
install.packages("remotes")
89-
90-
remotes::install_github(
91-
repo = "danielvartan/logolink",
92-
auth_token = Sys.getenv("GH_TOKEN")
93-
)
94-
95-
renv::snapshot()
96-
shell: Rscript {0}
97-
working-directory: './tests/qmd'
98-
9986
- name: Render Quarto
10087
run: |
10188
# Render Quarto

.github/workflows/test-check-netlogo.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ jobs:
1414
- {os: windows-latest, version: 'release'}
1515
- {os: macos-latest, version: 'release'}
1616
- {os: ubuntu-latest, version: 'release'}
17-
name: "${{matrix.config.os}} (${{matrix.config.version}})"
18-
runs-on: ${{matrix.config.os}}
17+
name: "${{ matrix.config.os }} (${{ matrix.config.version }})"
18+
runs-on: ${{ matrix.config.os }}
1919
env:
2020
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2121
permissions: read-all
@@ -26,7 +26,7 @@ jobs:
2626
- name: Set up NetLogo
2727
uses: danielvartan/netlogo-actions/setup-netlogo@v1
2828
with:
29-
version: ${{matrix.config.version}}
29+
version: ${{ matrix.config.version }}
3030
cache: 'true'
3131

3232
- name: Check NetLogo models

.github/workflows/test-setup-netlogo.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ jobs:
1717
- {os: ubuntu-latest, version: '6.4.0'}
1818
- {os: ubuntu-latest, version: 'release'}
1919
cache: ['false', 'true']
20-
name: "${{matrix.config.os}} (version: '${{matrix.config.version}}') (cache: '${{matrix.cache}}')"
21-
runs-on: ${{matrix.config.os}}
20+
name: "${{ matrix.config.os }} (version: '${{ matrix.config.version }}') (cache: '${{ matrix.cache }}')"
21+
runs-on: ${{ matrix.config.os }}
2222
env:
23-
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
23+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2424
steps:
2525
- name: Check out repository
2626
uses: actions/checkout@v4
2727

2828
- name: Set up NetLogo
2929
uses: ./setup-netlogo
3030
with:
31-
version: ${{matrix.config.version}}
32-
cache: ${{matrix.cache}}
31+
version: ${{ matrix.config.version }}
32+
cache: ${{ matrix.cache }}
3333

3434
- name: Run experiment
3535
run: |
@@ -48,7 +48,7 @@ jobs:
4848
--headless \
4949
--model "${model_path}/${model_file}" \
5050
--experiment 'Wolf Sheep Crossing' \
51-
--table '/tmp/table-output.csv'
51+
--table "${RUNNER_TEMP}/table-output.csv"
5252
53-
cat '/tmp/table-output.csv'
53+
cat "${RUNNER_TEMP}/table-output.csv"
5454
shell: bash

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"Clim",
3131
"cnpq",
3232
"compgen",
33+
"CRAN",
3334
"danielvartan",
3435
"Dcom",
3536
"dplyr",

check-netlogo/action.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ runs:
3232
# Validate arguments
3333
# set -x
3434
35-
if [[ "${{inputs.artifacts}}" != "true" ]] && \
36-
[[ "${{inputs.artifacts}}" != "false" ]]; then
35+
if [[ "${{ inputs.artifacts }}" != "true" ]] && \
36+
[[ "${{ inputs.artifacts }}" != "false" ]]; then
3737
echo \
3838
"Error: Invalid artifacts option" \
39-
"('${{inputs.artifacts}}')." \
39+
"('${{ inputs.artifacts }}')." \
4040
"Valid options are 'true' or 'false'."
4141
4242
exit 1
@@ -61,7 +61,7 @@ runs:
6161
# Search for NetLogo models
6262
# set -x
6363
64-
ignore_patterns="${{inputs.ignore}}"
64+
ignore_patterns="${{ inputs.ignore }}"
6565
netlogo_version=$(netlogo --headless --version | awk '{print $2}')
6666
6767
if [[ "${netlogo_version}" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
@@ -121,7 +121,7 @@ runs:
121121
122122
export JAVA_TOOL_OPTIONS="-Dcom.sun.media.jai.disableMediaLib=true"
123123
124-
artifacts_dir="${{steps.artifacts-dir.outputs.path}}"
124+
artifacts_dir="${{ steps.artifacts-dir.outputs.path }}"
125125
126126
while IFS= read -r model_file; do
127127
[[ -z "${model_file}" ]] && continue
@@ -161,7 +161,7 @@ runs:
161161
grep -o '<experiment name="[^"]*"' "${model_file}" \
162162
| sed 's/<experiment name="//;s/"$//'
163163
)
164-
done <<< "${{steps.netlogo-models.outputs.models}}"
164+
done <<< "${{ steps.netlogo-models.outputs.models }}"
165165
166166
shopt -s nullglob
167167
files=("${artifacts_dir}"/*.csv)
@@ -184,7 +184,7 @@ runs:
184184
inputs.artifacts != 'false'
185185
uses: actions/upload-artifact@v4
186186
with:
187-
name: experiments-output-${{runner.os}}
188-
path: ${{steps.artifacts-dir.outputs.path}}
187+
name: experiments-output-${{ runner.os }}
188+
path: ${{ steps.artifacts-dir.outputs.path }}
189189
retention-days: 90
190190
if-no-files-found: warn

setup-netlogo/action.yaml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,32 +29,32 @@ runs:
2929
# Validate arguments
3030
# set -x
3131
32-
if [[ ! "${{inputs.version}}" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]] && \
33-
[[ "${{inputs.version}}" != "release" ]]; then
32+
if [[ ! "${{ inputs.version }}" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]] && \
33+
[[ "${{ inputs.version }}" != "release" ]]; then
3434
echo \
3535
"Error: Invalid version format" \
36-
"('${{inputs.version}}')." \
36+
"('${{ inputs.version }}')." \
3737
"Use semantic versioning (e.g., '7.0.2') or use" \
3838
"'release' to get the latest stable release."
3939
4040
exit 1
4141
fi
4242
43-
if [[ "${{inputs.version}}" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
43+
if [[ "${{ inputs.version }}" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
4444
major_version="${BASH_REMATCH[1]}"
4545
minor_version="${BASH_REMATCH[2]}"
4646
4747
if (( major_version < 6 )) || \
48-
(( major_version == 6 && minor_version < 4 )) ; then
48+
(( major_version == 6 && minor_version < 4 )); then
4949
echo \
5050
"Error: Unsupported NetLogo version" \
51-
"('${{inputs.version}}')." \
51+
"('${{ inputs.version }}')." \
5252
"Only versions equal or greater than 6.4.0 are supported."
5353
5454
exit 1
5555
fi
5656
57-
if [[ "${{inputs.version}}" == "6.4.0" ]] &&
57+
if [[ "${{ inputs.version }}" == "6.4.0" ]] &&
5858
[[ "${RUNNER_ARCH}" =~ ^(ARM|ARM64)$ ]]; then
5959
echo \
6060
"Error: NetLogo 6.4.0 and earlier versions are not" \
@@ -64,11 +64,11 @@ runs:
6464
fi
6565
fi
6666
67-
if [[ "${{inputs.cache}}" != "true" ]] && \
68-
[[ "${{inputs.cache}}" != "false" ]]; then
67+
if [[ "${{ inputs.cache }}" != "true" ]] && \
68+
[[ "${{ inputs.cache }}" != "false" ]]; then
6969
echo \
7070
"Error: Invalid cache option" \
71-
"('${{inputs.cache}}')." \
71+
"('${{ inputs.cache }}')." \
7272
"Valid options are 'true' or 'false'."
7373
7474
exit 1
@@ -81,7 +81,7 @@ runs:
8181
# Get NetLogo version
8282
# set -x
8383
84-
if [[ "${{inputs.version}}" == "release" ]]; then
84+
if [[ "${{ inputs.version }}" == "release" ]]; then
8585
version_tag=$( \
8686
gh api repos/NetLogo/NetLogo/releases/latest -q .tag_name \
8787
)
@@ -95,7 +95,7 @@ runs:
9595
9696
NETLOGO_VERSION="${version_tag#v}"
9797
else
98-
NETLOGO_VERSION="${{inputs.version}}"
98+
NETLOGO_VERSION="${{ inputs.version }}"
9999
fi
100100
101101
echo "version=${NETLOGO_VERSION}" >> "${GITHUB_OUTPUT}"
@@ -136,8 +136,8 @@ runs:
136136
if: inputs.cache == 'true'
137137
uses: actions/cache@v4
138138
with:
139-
path: ${{steps.cache-path.outputs.path}}
140-
key: "netlogo-${{steps.netlogo-version.outputs.version}}-${{runner.os}}-${{runner.arch}}"
139+
path: ${{ steps.cache-path.outputs.path }}
140+
key: "netlogo-${{ steps.netlogo-version.outputs.version }}-${{ runner.os }}-${{ runner.arch }}"
141141

142142
- name: Choose correct bundle for OS type
143143
id: netlogo-bundle
@@ -210,7 +210,7 @@ runs:
210210
211211
repo="NetLogo/NetLogo"
212212
tag="v${NETLOGO_VERSION}"
213-
extension="${{steps.netlogo-bundle.outputs.extension}}"
213+
extension="${{ steps.netlogo-bundle.outputs.extension }}"
214214
215215
gh release download "$tag" \
216216
--repo "$repo" \
@@ -270,7 +270,7 @@ runs:
270270
# Install NetLogo
271271
# set -x
272272
273-
bundle="${{steps.netlogo-download.outputs.bundle}}"
273+
bundle="${{ steps.netlogo-download.outputs.bundle }}"
274274
275275
case ${RUNNER_OS} in
276276
"Linux")
@@ -364,7 +364,7 @@ runs:
364364
# Set environment variables
365365
# set -x
366366
367-
bundle="${{steps.netlogo-download.outputs.bundle}}"
367+
bundle="${{ steps.netlogo-download.outputs.bundle }}"
368368
369369
case ${RUNNER_OS} in
370370
"Linux" | "macOS")

0 commit comments

Comments
 (0)