Skip to content

Commit 9eda333

Browse files
authored
Merge branch 'main' into RHDHBUGS-986
2 parents 29a7cf4 + d01dfef commit 9eda333

File tree

39 files changed

+6827
-842
lines changed

39 files changed

+6827
-842
lines changed

.cursor/rules/ci-e2e-testing.mdc

Lines changed: 411 additions & 0 deletions
Large diffs are not rendered by default.

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ examples
1515
.ibm/images/*
1616
!.ibm/images/Dockerfile
1717
!.yarnrc.yml
18+
hermeto-cache

.github/actions/docker-build/action.yaml

Lines changed: 163 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ inputs:
2020
required: true
2121
password:
2222
description: The password to use for the registry
23-
required: true
23+
required: false
2424
username:
2525
description: The username to use for the registry
26-
required: true
26+
required: false
2727
imageName:
2828
description: The name of the image to build
2929
required: true
@@ -34,18 +34,30 @@ inputs:
3434
description: The labels for the Docker image
3535
required: false
3636
push:
37-
description: Whether to push the image
37+
description: Whether to push the image (automatically ignored and assumed to be false if enableHermeticBuild is true)
3838
required: true
3939
platform:
4040
description: "Target given CPU platform architecture (default: linux/amd64)"
4141
required: false
4242
default: linux/amd64
43+
enableHermeticBuild:
44+
description: Whether to enable hermetic builds using hermeto (currently only supported for linux/amd64)
45+
required: false
46+
default: 'false'
47+
componentDirectory:
48+
description: Path to the component directory for hermetic builds
49+
required: false
50+
default: '.'
51+
dockerfilePath:
52+
description: Path to the Dockerfile to use
53+
required: false
54+
default: 'docker/Dockerfile'
4355

4456
outputs:
4557
digest:
58+
description: The digest of the built Docker image
4659
value: ${{ steps.build.outputs.digest }}
4760

48-
4961
runs:
5062
using: composite
5163
steps:
@@ -63,11 +75,15 @@ runs:
6375
- name: Set up QEMU
6476
uses: docker/setup-qemu-action@v3
6577

66-
- name: Set up Docker Buildx
67-
uses: docker/setup-buildx-action@v3
78+
# - name: Install qemu dependency
79+
# shell: bash
80+
# run: |
81+
# set -ex
82+
# sudo apt-get update
83+
# sudo apt-get install -y qemu-user-static
6884

69-
- name: Log in to the Container registry
70-
if: ${{ inputs.push }}
85+
- name: Login to Registry
86+
if: ${{ inputs.push == 'true' && inputs.enableHermeticBuild != 'true' }}
7187
uses: docker/login-action@v3
7288
with:
7389
registry: ${{ inputs.registry }}
@@ -84,14 +100,151 @@ runs:
84100
labels: |
85101
${{ inputs.imageLabels }}
86102
87-
- name: Build and push Docker image
103+
# Hermetic Build Steps
104+
- name: Set up hermetic build variables
105+
if: ${{ inputs.enableHermeticBuild == 'true' }}
106+
shell: bash
107+
run: |
108+
echo "HERMETO_IMAGE=quay.io/konflux-ci/hermeto:latest" >> $GITHUB_ENV
109+
echo "LOCAL_CACHE_DIR=./hermeto-cache/$(basename ${{ inputs.componentDirectory }})" >> $GITHUB_ENV
110+
echo "COMPONENT_ABS_DIR=${{ github.workspace }}/${{ inputs.componentDirectory }}" >> $GITHUB_ENV
111+
112+
- name: Cache dependencies with hermeto
113+
if: ${{ inputs.enableHermeticBuild == 'true' }}
114+
shell: bash
115+
run: |
116+
set -ex
117+
118+
echo "=== Creating local cache directory ==="
119+
mkdir -p ${{ env.LOCAL_CACHE_DIR }} || echo "Failed to create local cache directory"
120+
121+
echo "=== Fetching dependencies with hermeto ==="
122+
# Build hermeto cache for rpm, yarn, and pip (currently does not support ARM64 due to quay.io/konflux-ci/hermeto:latest not having an arm64 image)
123+
podman run --rm -v "$PWD:/source:z" -v "$LOCAL_CACHE_DIR:/cachi2:z" -w /source "$HERMETO_IMAGE" \
124+
--log-level DEBUG \
125+
fetch-deps --dev-package-managers \
126+
--source . \
127+
--output /cachi2/output \
128+
'[{"type": "rpm", "path": "."}, {"type": "yarn","path": "."}, {"type": "yarn","path": "./dynamic-plugins"}, {"type": "pip","path": "./python", "allow_binary": "false"}]' || echo "Fetch-deps failed"
129+
130+
if [ -d ${{ env.LOCAL_CACHE_DIR }}/output ]; then
131+
echo "=== Output directory exists, running generate-env ==="
132+
133+
# Generate environment file
134+
podman run --rm -v "$PWD:/source:z" -v "$LOCAL_CACHE_DIR:/cachi2:z" -w /source "$HERMETO_IMAGE" \
135+
--log-level DEBUG \
136+
generate-env --format env \
137+
--output /cachi2/cachi2.env /cachi2/output
138+
139+
else
140+
echo "No output directory found, skipping generate-env"
141+
exit 1
142+
fi
143+
144+
if [ -d ${{ env.LOCAL_CACHE_DIR }}/output ]; then
145+
echo "=== Running inject-files ==="
146+
147+
podman run --rm -v "$PWD:/source:z" -v "$LOCAL_CACHE_DIR:/cachi2:z" -w /source "$HERMETO_IMAGE" \
148+
--log-level DEBUG \
149+
inject-files /cachi2/output || echo "Inject-files failed"
150+
151+
else
152+
echo "No output directory found, skipping inject-files"
153+
exit 1
154+
fi
155+
156+
echo LOCAL_CACHE_DIR_REALPATH=$(realpath "${{ env.LOCAL_CACHE_DIR }}") >> $GITHUB_ENV
157+
158+
- name: "Fix Cache Ownership for Non-Root Buildah"
159+
if: ${{ inputs.enableHermeticBuild == 'true' }}
160+
shell: bash
161+
run: |
162+
set -ex
163+
echo "=== Before ownership fix ==="
164+
ls -l ${{ env.LOCAL_CACHE_DIR_REALPATH }}
165+
echo "=== Attempting to fix ownership to runner user ==="
166+
sudo chown -R runner ${{ env.LOCAL_CACHE_DIR_REALPATH }}
167+
echo "=== After ownership fix ==="
168+
ls -l ${{ env.LOCAL_CACHE_DIR_REALPATH }}
169+
170+
- name: Transform Containerfile for hermetic build
171+
if: ${{ inputs.enableHermeticBuild == 'true' }}
172+
shell: bash
173+
run: |
174+
set -x
175+
176+
CONTAINERFILE_PATH="${{ inputs.dockerfilePath }}"
177+
178+
TRANSFORMED_CONTAINERFILE="${CONTAINERFILE_PATH}.hermeto"
179+
180+
# Copy original dockerfile for hermetic build modifications
181+
cp "$CONTAINERFILE_PATH" "$TRANSFORMED_CONTAINERFILE"
182+
183+
# Transform the dockerfile to simulate Konflux build
184+
# Configure dnf to use the cachi2 repo
185+
sed -i '/RUN *\(dnf\|microdnf\) install/i RUN rm -r /etc/yum.repos.d/* && cp /cachi2/output/deps/rpm/x86_64/repos.d/hermeto.repo /etc/yum.repos.d/' "$TRANSFORMED_CONTAINERFILE"
186+
187+
# Inject the cachi2 env variables to every RUN command
188+
sed -i 's/^\s*RUN /RUN . \/cachi2\/cachi2.env \&\& /' "$TRANSFORMED_CONTAINERFILE"
189+
190+
echo "TRANSFORMED_CONTAINERFILE=$TRANSFORMED_CONTAINERFILE" >> $GITHUB_ENV
191+
192+
- name: Build and push Docker image (Standard)
193+
if: ${{ inputs.enableHermeticBuild != 'true' }}
88194
uses: docker/build-push-action@v6
89195
id: build
90196
with:
91197
context: .
92-
file: docker/Dockerfile
198+
file: ${{ inputs.dockerfilePath }}
93199
push: ${{ inputs.push }}
94200
provenance: false
95201
tags: ${{ steps.meta.outputs.tags }}
96202
labels: ${{ steps.meta.outputs.labels }}
97203
platforms: ${{ inputs.platform }}
204+
205+
- name: "Build Docker Image (Hermetic)"
206+
id: hermetic-build
207+
if: ${{ inputs.enableHermeticBuild == 'true' }}
208+
uses: redhat-actions/buildah-build@7a95fa7ee0f02d552a32753e7414641a04307056 # v2.13
209+
with:
210+
containerfiles: ${{ inputs.dockerfilePath }}.hermeto
211+
context: .
212+
platform: ${{ inputs.platform }}
213+
tags: ${{ steps.meta.outputs.tags }}
214+
labels: ${{ steps.meta.outputs.labels }}
215+
extra-args: |
216+
--network=none
217+
--volume ${{ env.LOCAL_CACHE_DIR_REALPATH }}:/cachi2:z
218+
219+
- name: Set build output for hermetic builds
220+
if: ${{ inputs.enableHermeticBuild == 'true' }}
221+
shell: bash
222+
run: |
223+
echo "digest=${{ steps.hermetic-build.outputs.digest || 'no-digest-available' }}" >> $GITHUB_OUTPUT
224+
225+
- name: Save image as artifact (Hermetic)
226+
if: ${{ inputs.enableHermeticBuild == 'true' }}
227+
shell: bash
228+
run: |
229+
mkdir -p ./rhdh-podman-artifacts
230+
231+
# Extract the built image tags from the metadata
232+
TAGS_LIST="${{ steps.meta.outputs.tags }}"
233+
234+
# Save all the built images to tar (podman save can handle multiple tags)
235+
echo "Saving images with tags:"
236+
echo "$TAGS_LIST"
237+
238+
podman save $TAGS_LIST -o ./rhdh-podman-artifacts/image.tar
239+
240+
# Save metadata for the push workflow
241+
echo "$TAGS_LIST" > ./rhdh-podman-artifacts/tags.txt
242+
243+
- name: Upload image artifact
244+
if: ${{ inputs.enableHermeticBuild == 'true' }}
245+
uses: actions/upload-artifact@v4
246+
with:
247+
name: podman-image-${{ github.event.number || 'main' }}-${{ env.SHORT_SHA }}
248+
path: ./rhdh-podman-artifacts/
249+
retention-days: 1
250+
if-no-files-found: error

.github/workflows/e2e-tests-lint.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: E2E Tests
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'e2e-tests/**'
7+
push:
8+
branches:
9+
- "main"
10+
- "release-*"
11+
paths:
12+
- 'e2e-tests/**'
13+
14+
jobs:
15+
lint:
16+
name: ESLint and Prettier
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v5
22+
with:
23+
sparse-checkout: |
24+
e2e-tests
25+
.nvmrc
26+
.yarnrc.yml
27+
.yarn
28+
yarn.lock
29+
30+
- name: Set up Node.js
31+
uses: actions/setup-node@v4
32+
with:
33+
node-version-file: ".nvmrc"
34+
35+
- name: Install dependencies
36+
working-directory: ./e2e-tests
37+
run: yarn install --mode=skip-build
38+
39+
- name: Run ESLint check
40+
working-directory: ./e2e-tests
41+
run: yarn lint:check
42+
43+
- name: Run Prettier check
44+
working-directory: ./e2e-tests
45+
run: yarn prettier:check

.github/workflows/podman-push.yaml

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,6 @@ on:
66
- 'PR Build Image (Hermetic)'
77
types:
88
- completed
9-
workflow_call:
10-
inputs:
11-
buildId:
12-
type: string
13-
description: The build identifier for artifact naming (e.g., PR number, 'nightly', 'main')
14-
required: false
15-
shortSha:
16-
type: string
17-
description: The short SHA for artifact naming
18-
required: false
19-
registry:
20-
type: string
21-
description: The registry to push to
22-
required: false
23-
default: quay.io
249

2510
jobs:
2611
podman-push:
@@ -35,16 +20,11 @@ jobs:
3520
steps:
3621
- name: Determine artifact name
3722
run: |
38-
if [ "${{ github.event_name }}" == "workflow_run" ]; then
39-
# For workflow_run, extract from the event context
40-
BUILD_ID="${{ github.event.workflow_run.pull_requests[0].number || 'main' }}"
41-
SHORT_SHA="${{ github.event.workflow_run.head_sha }}"
42-
SHORT_SHA="${SHORT_SHA:0:8}"
43-
else
44-
# For workflow_call, use the inputs
45-
BUILD_ID="${{ inputs.buildId || 'main' }}"
46-
SHORT_SHA="${{ inputs.shortSha }}"
47-
fi
23+
# For workflow_run, extract from the event context
24+
BUILD_ID="${{ github.event.workflow_run.pull_requests[0].number || 'main' }}"
25+
SHORT_SHA="${{ github.event.workflow_run.head_sha }}"
26+
SHORT_SHA="${SHORT_SHA:0:8}"
27+
4828
4929
echo "SHORT_SHA=$SHORT_SHA" >> $GITHUB_ENV
5030
ARTIFACT_NAME="podman-image-${BUILD_ID}-${SHORT_SHA}"
@@ -99,13 +79,8 @@ jobs:
9979
podman load -i ./rhdh-podman-artifacts/image.tar
10080
10181
# Read metadata
102-
REGISTRY=$(cat ./rhdh-podman-artifacts/registry.txt)
103-
IMAGE_NAME=$(cat ./rhdh-podman-artifacts/imageName.txt)
10482
TAGS_LIST=$(cat ./rhdh-podman-artifacts/tags.txt)
105-
106-
echo "REGISTRY=$REGISTRY" >> $GITHUB_ENV
107-
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_OUTPUT
108-
83+
10984
echo "Loaded images:"
11085
podman images
11186
@@ -127,7 +102,6 @@ jobs:
127102

128103
- name: Extract PR info for commenting
129104
id: get-pr
130-
if: ${{ github.event_name == 'workflow_run' }}
131105
env:
132106
WORKFLOW_RUN_PR_NUMBER: ${{ github.event.workflow_run.pull_requests[0].number || '' }}
133107
WORKFLOW_RUN_HEAD_SHA: ${{ github.event.workflow_run.head_sha }}

0 commit comments

Comments
 (0)