Skip to content

Commit ab4bf1e

Browse files
authored
CI: Fix and enable scanning GitHub Actions with actionlint and zizmor (OSGeo#6296)
1 parent 341a3fd commit ab4bf1e

23 files changed

+354
-232
lines changed

.github/actions/create-upload-suggestions/action.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@ runs:
145145
- name: List all changed files tracked and untracked files
146146
shell: bash
147147
run: |
148-
echo "Changed files: ${{ steps.git-changed-files.outputs.CHANGED_FILES }}"
148+
echo "Changed files: ${CHANGED_FILES}"
149+
env:
150+
CHANGED_FILES: ${{ steps.git-changed-files.outputs.CHANGED_FILES }}
149151
- name: Add job summary without changed files
150152
shell: bash
151153
if: ${{ steps.files_changed.outputs.files_changed == 'false' }}

.github/workflows/additional_checks.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ jobs:
2323
additional-checks:
2424
name: Additional checks
2525
runs-on: ubuntu-24.04
26+
permissions:
27+
contents: read
2628

2729
steps:
2830
- name: Checkout repository contents
@@ -37,6 +39,10 @@ jobs:
3739
python-version: "3.13"
3840
- name: Install uv and restore its cache
3941
uses: astral-sh/setup-uv@557e51de59eb14aaaba2ed9621916900a91d50c6 # v6.6.1
42+
with:
43+
# To not have the last commit JSON and release notes files affected on
44+
# releases, if copying the contents displayed in the CI logs.
45+
enable-cache: false
4046

4147
- name: Check that files with the same content are the same
4248
run: |
@@ -56,11 +62,12 @@ jobs:
5662
# Using the last 30 commits (for branches, tags, and PRs).
5763
# End is the current (latest) commit.
5864
python ./utils/generate_release_notes.py log \
59-
${{ github.ref_name }} \
60-
$(git rev-parse HEAD~30) \
65+
"${GITHUB_REF_NAME}" \
66+
"$(git rev-parse HEAD~30)" \
6167
""
6268
- name: "Cache pre-commit"
63-
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
69+
# Not used for releases, only for running pre-commit
70+
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 # zizmor: ignore[cache-poisoning]
6471
with:
6572
path: ~/.cache/pre-commit
6673
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}

.github/workflows/cmake.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,21 @@ jobs:
2626
build-cmake:
2727
runs-on: ubuntu-22.04
2828
env:
29-
CMakeVersion: "3.22.0"
29+
CMAKE_VERSION: "3.22.0"
3030
steps:
3131
- name: Checkout GRASS
3232
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
3333
with:
3434
persist-credentials: false
3535
- name: Install CMake
3636
run: |
37-
cd ${GITHUB_WORKSPACE}
38-
arch=$(echo $(uname -s)-$(uname -m) | awk '{print tolower($0)}')
39-
v=v${{ env.CMakeVersion }}/cmake-${{ env.CMakeVersion }}-${arch}.tar.gz
40-
wget https://github.com/Kitware/CMake/releases/download/$v
41-
tar xzf cmake-${{ env.CMakeVersion }}-${arch}.tar.gz
42-
echo "CMAKE_DIR=$GITHUB_WORKSPACE/cmake-${{ env.CMakeVersion }}-${arch}/bin" >> $GITHUB_ENV
43-
echo "$GITHUB_WORKSPACE/cmake-${{ env.CMakeVersion }}-${arch}/bin" >> $GITHUB_PATH
37+
cd "${GITHUB_WORKSPACE}" || exit
38+
arch="$(echo "$(uname -s)"-"$(uname -m)" | awk '{print tolower($0)}')"
39+
v="v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-${arch}.tar.gz"
40+
wget "https://github.com/Kitware/CMake/releases/download/$v"
41+
tar xzf "cmake-${CMAKE_VERSION}-${arch}.tar.gz"
42+
echo "CMAKE_DIR=${GITHUB_WORKSPACE}/cmake-${CMAKE_VERSION}-${arch}/bin" >> "${GITHUB_ENV}"
43+
echo "${GITHUB_WORKSPACE}/cmake-${CMAKE_VERSION}-${arch}/bin" >> "${GITHUB_PATH}"
4444
- run: |
4545
cmake --version
4646
- name: Install dependencies
@@ -58,25 +58,25 @@ jobs:
5858
ldd --version
5959
- name: Create installation directory
6060
run: |
61-
mkdir $HOME/install
61+
mkdir "${HOME}/install"
6262
- name: Configure
6363
run: |
64-
cmake ${CMAKE_OPTIONS} -S $GITHUB_WORKSPACE -B $GITHUB_WORKSPACE/build -G Ninja \
65-
-DCMAKE_INSTALL_PREFIX=$HOME/install -DWITH_NLS=ON -DWITH_GUI=OFF -DWITH_DOCS=OFF \
64+
cmake -S "${GITHUB_WORKSPACE}" -B "${GITHUB_WORKSPACE}/build" -G Ninja \
65+
-DCMAKE_INSTALL_PREFIX="${HOME}/install" -DWITH_NLS=ON -DWITH_GUI=OFF -DWITH_DOCS=OFF \
6666
-DWITH_READLINE=ON -DWITH_ODBC=ON -DWITH_NETCDF=ON -DWITH_BZLIB=ON
6767
- name: Print CMakeCache.txt
6868
shell: bash -el {0}
6969
run: |
70-
cat ${GITHUB_WORKSPACE}/build/CMakeCache.txt
70+
cat "${GITHUB_WORKSPACE}/build/CMakeCache.txt"
7171
- name: Build
7272
run: |
73-
cmake --build build --verbose -j$(nproc)
73+
cmake --build build --verbose -j"$(nproc)"
7474
- name: Install
7575
run: |
76-
cmake --install $GITHUB_WORKSPACE/build --verbose
76+
cmake --install "${GITHUB_WORKSPACE}/build" --verbose
7777
- name: Add the bin directory to PATH
7878
run: |
79-
echo "$HOME/install/bin" >> $GITHUB_PATH
79+
echo "${HOME}/install/bin" >> "${GITHUB_PATH}"
8080
- name: Print installed versions
8181
if: always()
8282
run: .github/workflows/print_versions.sh

.github/workflows/codeql-analysis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ jobs:
7070
7171
- name: Set LD_LIBRARY_PATH for compilation
7272
run: |
73-
echo "LD_LIBRARY_PATH=${HOME}/install/lib" >> $GITHUB_ENV
73+
echo "LD_LIBRARY_PATH=${HOME}/install/lib" >> "${GITHUB_ENV}"
7474
7575
- name: Set number of cores for compilation
7676
run: |
77-
echo "MAKEFLAGS=-j$(nproc)" >> $GITHUB_ENV
77+
echo "MAKEFLAGS=-j$(nproc)" >> "${GITHUB_ENV}"
7878
7979
- name: Build
8080
if: ${{ matrix.language == 'c-cpp' }}

.github/workflows/coverity.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
3131
- name: Create installation directory
3232
run: |
33-
mkdir $HOME/install
33+
mkdir "${HOME}/install"
3434
3535
- name: Download Coverity Build Tool
3636
run: |
@@ -43,11 +43,11 @@ jobs:
4343

4444
- name: Set number of cores for compilation
4545
run: |
46-
echo "MAKEFLAGS=-j$(nproc)" >> $GITHUB_ENV
46+
echo "MAKEFLAGS=-j$(nproc)" >> "${GITHUB_ENV}"
4747
4848
- name: Set LD_LIBRARY_PATH for compilation
4949
run: |
50-
echo "LD_LIBRARY_PATH=$HOME/install/lib" >> $GITHUB_ENV
50+
echo "LD_LIBRARY_PATH=${HOME}/install/lib" >> "${GITHUB_ENV}"
5151
5252
- name: Print build environment variables
5353
run: |
@@ -57,11 +57,11 @@ jobs:
5757
5858
- name: Configure
5959
run: |
60-
echo "CFLAGS=${{ env.CFLAGS }}" >> $GITHUB_ENV
61-
echo "CXXFLAGS=${{ env.CXXFLAGS }}" >> $GITHUB_ENV
60+
echo "CFLAGS=${CFLAGS}" >> "${GITHUB_ENV}"
61+
echo "CXXFLAGS=${CXXFLAGS}" >> "${GITHUB_ENV}"
6262
./configure \
6363
--enable-largefile \
64-
--prefix="$HOME/install/" \
64+
--prefix="${HOME}/install/" \
6565
--with-blas \
6666
--with-bzlib \
6767
--with-cxx \
@@ -87,7 +87,8 @@ jobs:
8787
- name: Build with cov-build
8888
run: |
8989
pwd
90-
export PATH="$(pwd)/cov-analysis-linux64/bin:${PATH}"
90+
PATH="$(pwd)/cov-analysis-linux64/bin:${PATH}"
91+
export PATH
9192
cov-build --dir cov-int make
9293
9394
- name: Put results into Tarball

.github/workflows/create_release_draft.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ jobs:
4141
python-version: '3.13'
4242
- name: Create output directory
4343
run: |
44-
mkdir ${{ env.OUT_DIR }}
44+
mkdir "${OUT_DIR}"
4545
- name: Generate ChangeLog file
4646
run: |
4747
python utils/gitlog2changelog.py
48-
mv ChangeLog ${{ env.OUT_DIR }}/ChangeLog
49-
gzip ${{ env.OUT_DIR }}/ChangeLog
48+
mv ChangeLog "${OUT_DIR}/ChangeLog"
49+
gzip "${OUT_DIR}/ChangeLog"
5050
- name: Generate Git derived data files
5151
run: |
5252
echo "Generate VERSION_GIT file:"
@@ -58,21 +58,21 @@ jobs:
5858
echo "Create core modules patch file:"
5959
git add core_modules_with_last_commit.json
6060
git diff --cached > \
61-
${{ env.OUT_DIR }}/core_modules_with_last_commit.patch
61+
"${OUT_DIR}/core_modules_with_last_commit.patch"
6262
- name: Create tarballs (for tags only)
6363
if: startsWith(github.ref, 'refs/tags/')
6464
run: |
6565
cd ..
66-
tar -cvf ${{ env.OUT_DIR }}/${{ env.GRASS }}.tar \
66+
tar -cvf "${OUT_DIR}/${GRASS}.tar" \
6767
--exclude=".gi*" --exclude=".tr*" \
68-
--transform s/grass/${{ env.GRASS }}/ grass
69-
cd ${{ env.OUT_DIR }}
70-
gzip -9k ${{ env.GRASS }}.tar
71-
md5sum ${{ env.GRASS }}.tar.gz > ${{ env.GRASS }}.tar.gz.md5
72-
sha256sum ${{ env.GRASS }}.tar.gz > ${{ env.GRASS }}.tar.gz.sha256
73-
xz -9e ${{ env.GRASS }}.tar
74-
md5sum ${{ env.GRASS }}.tar.xz > ${{ env.GRASS }}.tar.xz.md5
75-
sha256sum ${{ env.GRASS }}.tar.xz > ${{ env.GRASS }}.tar.xz.sha256
68+
--transform s/grass/"${GRASS}"/ grass
69+
cd "${OUT_DIR}" || exit
70+
gzip -9k "${GRASS}.tar"
71+
md5sum "${GRASS}.tar.gz" > "${GRASS}.tar.gz.md5"
72+
sha256sum "${GRASS}.tar.gz" > "${GRASS}.tar.gz.sha256"
73+
xz -9e "${GRASS}.tar"
74+
md5sum "${GRASS}.tar.xz" > "${GRASS}.tar.xz.md5"
75+
sha256sum "${GRASS}.tar.xz" > "${GRASS}.tar.xz.sha256"
7676
- name: Publish draft distribution to GitHub (for tags only)
7777
if: startsWith(github.ref, 'refs/tags/')
7878
uses: softprops/action-gh-release@6cbd405e2c4e67a21c47fa9e383d020e4e28b836 # v2.3.3

.github/workflows/docker.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ jobs:
105105
|| github.ref == format('refs/heads/{0}', steps.tag-branch.outputs.latest_rel_branch)
106106
}}"
107107
echo "latest=${latest}" >> "${GITHUB_OUTPUT}"
108-
echo "latest is $latest"
108+
echo "latest is ${latest}"
109109
echo "current=${current}" >> "${GITHUB_OUTPUT}"
110-
echo "current is $current"
110+
echo "current is ${current}"
111111
- name: Docker meta
112112
id: meta
113113
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
@@ -160,7 +160,9 @@ jobs:
160160
&& format('type=gha,scope={0}', matrix.os) || '' }}
161161
cache-to: type=gha,mode=max,scope=${{ matrix.os }}
162162
- name: Image digest
163-
run: echo ${{ steps.docker_build.outputs.digest }}
163+
run: echo "${STEPS_DOCKER_BUILD_OUTPUTS_DIGEST}"
164+
env:
165+
STEPS_DOCKER_BUILD_OUTPUTS_DIGEST: ${{ steps.docker_build.outputs.digest }}
164166
- name: Attest docker.io image
165167
uses: actions/attest-build-provenance@977bb373ede98d70efdf65b84cb5f73e068dcc2a # v3.0.0
166168
# If there isn't a digest, an annotation cannot be added

.github/workflows/documentation.yml

Lines changed: 47 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,29 @@ jobs:
4545
xargs -a <(awk '! /^ *(#|$)/' "grass/.github/workflows/apt.txt") -r -- \
4646
sudo apt-get install -y --no-install-recommends --no-install-suggests
4747
48-
- name: Set up Python
48+
- name: Set up Python (with cache)
49+
if: ${{ contains(fromJSON('["push", "pull_request"]'), github.event_name) }}
50+
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
51+
with:
52+
python-version: ${{ env.PYTHON_VERSION }}
53+
cache: pip # zizmor: ignore[cache-poisoning] Assuming push event is not used for tags
54+
55+
- name: Set up Python (no cache, use for release artifacts)
56+
if: ${{ !contains(fromJSON('["push", "pull_request"]'), github.event_name) }}
4957
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
5058
with:
5159
python-version: ${{ env.PYTHON_VERSION }}
52-
cache: pip
5360

5461
- name: Set version variables
5562
run: |
56-
cd grass
57-
eval $(./utils/update_version.py status --bash)
58-
echo "MAJOR=$MAJOR" >> $GITHUB_ENV
59-
echo "MINOR=$MINOR" >> $GITHUB_ENV
60-
echo "VERSION=$VERSION" >> $GITHUB_ENV
61-
echo "YEAR=$YEAR" >> $GITHUB_ENV
63+
cd grass || exit
64+
eval "$(./utils/update_version.py status --bash)"
65+
{
66+
echo "MAJOR=${MAJOR}"
67+
echo "MINOR=${MINOR}"
68+
echo "VERSION=${VERSION}"
69+
echo "YEAR=${YEAR}"
70+
} >> "${GITHUB_ENV}"
6271
6372
- name: Checkout addons
6473
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
@@ -69,13 +78,14 @@ jobs:
6978
fetch-depth: 0
7079
persist-credentials: false
7180

72-
- name: ccache
81+
- name: ccache (do not use for release artifacts)
7382
uses: hendrikmuhs/ccache-action@bfa03e1de4d7f7c3e80ad9109feedd05c4f5a716 # v1.2.19
83+
if: ${{ !contains(fromJSON('["push", "pull_request"]'), github.event_name) }}
7484
with:
7585
create-symlink: true
7686
verbose: 2
7787
evict-old-files: 7d
78-
key: ${{ github.workflow }}-${{ github.job }}-grass${{ env.MAJOR }}-${{ matrix.python-version }}
88+
key: ${{ github.workflow }}-${{ github.job }}-grass${{ env.MAJOR }}-${{ env.PYTHON_VERSION }}
7989

8090
- name: Install Python dependencies
8191
# We install both core and addon dependencies, but we don't install any
@@ -86,6 +96,7 @@ jobs:
8696
pip install -r grass-addons/.github/workflows/requirements.txt
8797
8898
- uses: rui314/setup-mold@725a8794d15fc7563f59595bd9556495c0564878 # v1
99+
if: ${{ !contains(fromJSON('["push", "pull_request"]'), github.event_name) }}
89100

90101
- name: Create installation directory
91102
run: |
@@ -170,11 +181,11 @@ jobs:
170181
- name: Compile addons
171182
run: |
172183
./grass-addons/utils/cronjobs_osgeo_lxd/compile_addons_git.sh \
173-
"$MAJOR" \
174-
"$MINOR" \
175-
$(pwd)/grass-addons/src \
176-
$(grass --config path) \
177-
$(pwd)/addons-build-dir \
184+
"${MAJOR}" \
185+
"${MINOR}" \
186+
"$(pwd)/grass-addons/src" \
187+
"$(grass --config path)" \
188+
"$(pwd)/addons-build-dir" \
178189
grass
179190
180191
- name: Get target path for Markdown files
@@ -183,24 +194,27 @@ jobs:
183194
184195
- name: Move from build to target directory
185196
run: |
186-
mkdir "$MKDOCS_DIR/source/addons"
187-
mv -v addons-build-dir/docs/md/source/* "$MKDOCS_DIR/source/addons"
197+
mkdir "${MKDOCS_DIR}/source/addons"
198+
mv -v addons-build-dir/docs/md/source/* "${MKDOCS_DIR}/source/addons"
188199
189200
- name: Build index
190201
run: |
191-
export ARCH="$(grass --config arch)"
192-
export ARCH_DISTDIR="$(grass --config path)"
193-
export VERSION_NUMBER="$VERSION"
202+
ARCH="$(grass --config arch)"
203+
ARCH_DISTDIR="$(grass --config path)"
204+
export ARCH
205+
export ARCH_DISTDIR
206+
export VERSION_NUMBER="${VERSION}"
194207
grass --tmp-project XY --exec \
195-
python grass/man/build_full_index.py md index "$MKDOCS_DIR/source/addons" addons
208+
python grass/man/build_full_index.py md index "${MKDOCS_DIR}/source/addons" addons
196209
197210
- name: Copy shared files to addons
198211
run: |
199-
cd "$MKDOCS_DIR/source"
212+
cd "${MKDOCS_DIR}/source" || exit
200213
# This should match directories with color tables and other files
201214
# linked from the pages.
215+
# shellcheck disable=SC2010,SC2035 # TODO: Address these two issues
202216
for name in $(ls -1d */ | grep -vE "^(addons|libpython)/$"); do
203-
cp -rv $name addons
217+
cp -rv "${name}" addons
204218
done
205219
206220
- name: Get mkdocs
@@ -209,30 +223,30 @@ jobs:
209223
210224
- name: Run mkdocs
211225
run: |
212-
cd grass
213-
eval $(./utils/update_version.py status --bash)
226+
cd grass || exit
227+
eval "$(./utils/update_version.py status --bash)"
214228
cd ..
215229
export SITE_NAME="GRASS $VERSION Documentation"
216230
export COPYRIGHT="&copy; 2003-$YEAR GRASS Development Team, GRASS $VERSION Documentation"
217-
cd $MKDOCS_DIR
231+
cd "${MKDOCS_DIR}" || exit
218232
mkdocs build
219233
220234
- name: Build Sphinx documentation
221235
run: |
222236
pip install -r "grass/python/grass/docs/requirements.txt"
223-
cd grass
237+
cd grass || exit
224238
make sphinxdoclib
225239
ARCH="$(grass --config arch)"
226-
mv -v dist.$ARCH/docs/html/libpython $MKDOCS_DIR/site
240+
mv -v dist."${ARCH}/docs/html/libpython" "${MKDOCS_DIR}/site"
227241
228242
- name: Merge Sphinx and MkDocs Sitemaps
229243
run: |
230-
cd grass
244+
cd grass || exit
231245
python utils/merge_sitemaps.py \
232-
--mkdocs-sitemap "$MKDOCS_DIR/site/sitemap.xml" \
233-
--sphinx-sitemap "$MKDOCS_DIR/site/libpython/sitemap.xml" \
234-
--output "$MKDOCS_DIR/site/sitemap.xml" \
235-
--version $VERSION -o
246+
--mkdocs-sitemap "${MKDOCS_DIR}/site/sitemap.xml" \
247+
--sphinx-sitemap "${MKDOCS_DIR}/site/libpython/sitemap.xml" \
248+
--output "${MKDOCS_DIR}/site/sitemap.xml" \
249+
--version "${VERSION}" -o
236250
237251
- name: Make logs available
238252
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2

0 commit comments

Comments
 (0)