Skip to content

Commit bf40843

Browse files
committed
testing simplified workflow
1 parent dacaca1 commit bf40843

4 files changed

Lines changed: 206 additions & 266 deletions

File tree

.github/workflows/sanitize.yml

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: Sanitize
2+
23
permissions:
34
contents: read
45

@@ -10,12 +11,14 @@ concurrency:
1011
cancel-in-progress: true
1112

1213
on:
13-
push:
14-
branches: [ main ]
15-
tags: [ 'v*' ]
14+
workflow_dispatch:
15+
pull_request:
1616
paths-ignore:
1717
- "**/*.md"
18-
pull_request:
18+
19+
merge_group:
20+
push:
21+
branches: [ main ]
1922
paths-ignore:
2023
- "**/*.md"
2124

@@ -28,20 +31,22 @@ jobs:
2831
steps:
2932
- name: Checkout repository
3033
uses: actions/checkout@v6
34+
with:
35+
fetch-depth: 0
3136

3237
- id: scan
3338
name: Build matrix
3439
shell: bash
3540
run: |
3641
set -euo pipefail
37-
./ci/sanitizers_tags.sh
42+
./ci/distros_tags.sh
3843
3944
- name: Fail if matrix is empty
4045
shell: bash
4146
run: |
4247
set -euo pipefail
4348
if [[ -z "${{ steps.scan.outputs.matrix_sanitize }}" ]]; then
44-
echo "matrix_sanitize output is empty. Check ci/sanitizers_tags.sh writing to GITHUB_OUTPUT."
49+
echo "matrix_sanitize output is empty. Check ci/distros_tags.sh writing to GITHUB_OUTPUT."
4550
exit 1
4651
fi
4752
@@ -51,7 +56,7 @@ jobs:
5156
echo '${{ steps.scan.outputs.matrix_sanitize }}'
5257
5358
build-with-sanitizer:
54-
name: ${{ matrix.baseos }}/${{ matrix.baseos_tag }} ${{ matrix.arch }} ${{ matrix.sanitizer }}
59+
name: ${{ matrix.image }}/${{ matrix.image_tag }} ${{ matrix.arch }} ${{ matrix.sanitizer }}
5560
needs: [ discover ]
5661
strategy:
5762
fail-fast: false
@@ -62,46 +67,45 @@ jobs:
6267
steps:
6368
- name: Checkout
6469
uses: actions/checkout@v6
70+
with:
71+
fetch-depth: 0
6572

66-
- name: Sanitizer - ${{ matrix.sanitizer }}
73+
- name: Build and test
6774
shell: bash
6875
env:
6976
GEMC_SKIP_PYTHON_ENV_INSTALL: "1"
7077
run: |
7178
set -euo pipefail
72-
73-
echo "Starting manual build for sanitizer: ${{ matrix.sanitizer }}"
74-
7579
export DOCKER_ENTRYPOINT_SOURCE_ONLY=1
7680
. /usr/local/bin/docker-entrypoint.sh
77-
module load geant4/"${{ matrix.g4v }}"
78-
81+
module load geant4/"${{ matrix.geant4_tag }}"
7982
./ci/build.sh "${{ matrix.sanitizer }}"
80-
81-
echo "Manual build for sanitizer: ${{ matrix.sanitizer }} completed"
8283
8384
- name: Package sanitizer logs
8485
if: ${{ always() }} # run regardless of earlier step outcomes
8586
shell: bash
8687
run: |
8788
set -euo pipefail
89+
echo "LOG_TAR=" >> "$GITHUB_ENV"
8890
src="/root/src/logs"
8991
outdir="$GITHUB_WORKSPACE/_artifacts"
92+
tarball="logs-${{ matrix.image }}-${{ matrix.arch }}-${{ matrix.sanitizer }}.tgz"
9093
mkdir -p "$outdir"
9194
9295
if [[ -d "$src" ]]; then
93-
tar -C "/root/src" -czf "$outdir/logs-${{ matrix.baseos }}-${{ matrix.arch }}-${{ matrix.sanitizer }}.tgz" "logs"
96+
tar -C "/root/src" -czf "$outdir/$tarball" "logs"
97+
echo "LOG_TAR=$outdir/$tarball" >> "$GITHUB_ENV"
9498
echo "Packaged logs from $src"
9599
else
96100
echo "No logs directory at $src"
97101
fi
98102
99103
- name: Upload sanitizer logs (artifact)
100-
if: ${{ always() }} # run regardless of earlier step outcomes
104+
if: ${{ always() && env.LOG_TAR != '' }}
101105
uses: actions/upload-artifact@v7
102106
with:
103-
name: logs-${{ matrix.baseos }}-${{ matrix.arch }}-${{ matrix.sanitizer }}
104-
path: ${{ github.workspace }}/_artifacts/logs-${{ matrix.baseos }}-${{ matrix.arch }}-${{ matrix.sanitizer }}.tgz
107+
name: logs-${{ matrix.image }}-${{ matrix.arch }}-${{ matrix.sanitizer }}
108+
path: ${{ env.LOG_TAR }}
105109
if-no-files-found: warn
106110
retention-days: 14
107111

.github/workflows/test.yml

Lines changed: 36 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
# Build and test GEMC images without publishing containers.
21
name: Test
32

43
permissions:
54
contents: read
6-
packages: read
75

86
env:
9-
GEMC_TAG: dev
10-
GEANT4_TAG: 11.4.1
117
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
12-
DOCKER_BUILD_SUMMARY: false
138

149
concurrency:
1510
group: gemc-test-${{ github.ref }}
@@ -24,13 +19,12 @@ on:
2419
merge_group:
2520
push:
2621
branches: [ main ]
27-
tags: [ '*' ]
2822
paths-ignore:
2923
- "**/*.md"
3024

3125
jobs:
3226
discover:
33-
name: Create Job Matrix
27+
name: Create job matrix
3428
runs-on: ubuntu-latest
3529
outputs:
3630
matrix_build: ${{ steps.scan.outputs.matrix_build }}
@@ -42,7 +36,24 @@ jobs:
4236

4337
- id: scan
4438
name: Build matrix
45-
run: ci/distros_tags.sh
39+
shell: bash
40+
run: |
41+
set -euo pipefail
42+
./ci/distros_tags.sh
43+
44+
- name: Fail if matrix is empty
45+
shell: bash
46+
run: |
47+
set -euo pipefail
48+
if [[ -z "${{ steps.scan.outputs.matrix_build }}" ]]; then
49+
echo "matrix_build output is empty. Check ci/distros_tags.sh writing to GITHUB_OUTPUT."
50+
exit 1
51+
fi
52+
53+
- name: Show matrix (debug)
54+
shell: bash
55+
run: |
56+
echo '${{ steps.scan.outputs.matrix_build }}'
4657
4758
build:
4859
name: ${{ matrix.image }}/${{ matrix.image_tag }} ${{ matrix.arch }}
@@ -51,83 +62,45 @@ jobs:
5162
strategy:
5263
fail-fast: false
5364
matrix: ${{ fromJSON(needs.discover.outputs.matrix_build) }}
54-
env:
55-
CACHE_REF: type=registry,ref=ghcr.io/${{ github.repository }}:cache-test-${{ matrix.arch }}
65+
container: ${{ matrix.container }}
66+
5667
steps:
57-
- name: Checkout repository
68+
- name: Checkout
5869
uses: actions/checkout@v6
5970
with:
6071
fetch-depth: 0
6172

62-
- name: Free up disk space
63-
uses: ./.github/actions/free-disk-space
64-
with:
65-
prune_docker: "true"
66-
show_tree: "true"
67-
68-
- name: Set up Buildx
69-
uses: docker/setup-buildx-action@v4
73+
- name: Build and test
74+
shell: bash
7075

71-
- name: Log in to GHCR
72-
uses: docker/login-action@v4
73-
with:
74-
registry: ghcr.io
75-
username: ${{ github.actor }}
76-
password: ${{ secrets.GITHUB_TOKEN }}
7776

78-
- name: Generate Dockerfile
79-
shell: bash
8077
run: |
81-
python3 ci/dockerfile_creator.py \
82-
-i "${{ matrix.image }}" \
83-
-t "${{ matrix.image_tag }}" \
84-
--gemc-version "${{ matrix.gemc_tag || env.GEMC_TAG }}" \
85-
--geant4-version "${{ matrix.geant4_tag || env.GEANT4_TAG }}" \
86-
--source context \
87-
> Dockerfile.generated
88-
cat Dockerfile.generated
89-
90-
- name: Build and test
91-
uses: docker/build-push-action@v7
92-
with:
93-
pull: true
94-
context: .
95-
file: ./Dockerfile.generated
96-
target: final
97-
platforms: ${{ matrix.platform }}
98-
push: false
99-
cache-from: ${{ env.CACHE_REF }}
100-
101-
- name: Export logs
102-
uses: docker/build-push-action@v7
103-
with:
104-
pull: true
105-
context: .
106-
file: ./Dockerfile.generated
107-
target: logs-export
108-
platforms: ${{ matrix.platform }}
109-
push: false
110-
cache-from: ${{ env.CACHE_REF }}
111-
outputs: type=local,dest=${{ runner.temp }}/artifacts/${{ matrix.logs_dir }}
78+
set -euo pipefail
79+
export DOCKER_ENTRYPOINT_SOURCE_ONLY=1
80+
. /usr/local/bin/docker-entrypoint.sh
81+
module load geant4/"${{ matrix.geant4_tag || env.GEANT4_TAG }}"
82+
./ci/build.sh
11283
11384
- name: Pack logs
85+
if: ${{ always() }}
11486
shell: bash
11587
run: |
11688
set -euo pipefail
11789
echo "LOG_TAR=" >> "$GITHUB_ENV"
118-
LOGROOT="${{ runner.temp }}/artifacts/${{ matrix.logs_dir }}"
90+
LOGROOT="/root/src"
91+
OUTDIR="$GITHUB_WORKSPACE/_artifacts"
11992
TAR="logs-${{ matrix.gemc_tag }}-${{ matrix.image }}-${{ matrix.image_tag }}"
12093
TAR="${TAR}-${{ matrix.arch }}.tgz"
12194
if [[ -d "$LOGROOT/logs" ]]; then
122-
cd "$LOGROOT"
123-
tar -czf "$TAR" logs
124-
echo "LOG_TAR=$LOGROOT/$TAR" >> "$GITHUB_ENV"
95+
mkdir -p "$OUTDIR"
96+
tar -C "$LOGROOT" -czf "$OUTDIR/$TAR" logs
97+
echo "LOG_TAR=$OUTDIR/$TAR" >> "$GITHUB_ENV"
12598
else
12699
echo "No exported logs found at $LOGROOT/logs"
127100
fi
128101
129102
- name: Upload logs
130-
if: ${{ env.LOG_TAR != '' }}
103+
if: ${{ always() && env.LOG_TAR != '' }}
131104
uses: actions/upload-artifact@v7
132105
with:
133106
name: logs-${{ matrix.gemc_tag }}-${{ matrix.image }}-${{ matrix.image_tag }}-${{ matrix.arch }}

0 commit comments

Comments
 (0)