Skip to content

Commit e702686

Browse files
authored
Merge pull request #195 from shawn-hurley/cross-org-ci
✨ Adding cross org CI with comment on pr
2 parents 0600691 + c1c3407 commit e702686

4 files changed

Lines changed: 354 additions & 10 deletions

File tree

.github/workflows/build-nightly-images.yaml

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ jobs:
3131
build-images:
3232
name: Build Images ${{ matrix.image.image }}-${{ matrix.os.arch }}
3333
runs-on: ${{ matrix.os.runner }}
34+
env:
35+
GONOSUMCHECK: "*"
36+
GOFLAGS: "-mod=mod"
37+
GOPROXY: direct
3438
strategy:
3539
fail-fast: false
3640
matrix:
@@ -42,28 +46,52 @@ jobs:
4246
uses: actions/checkout@v5
4347
with:
4448
repository: ${{ matrix.image.repo }}
45-
ref: ${{ (inputs.tested_repo == '' || matrix.image.repo == inputs.tested_repo) && inputs.branch || github.base_ref || github.ref_name }}
49+
# This will:
50+
# Use an override ref if set for the matrix
51+
# Use the branch that is passed in as input
52+
# If a pr, will use the base_ref
53+
# If not a pr will use the ref
54+
ref: ${{ matrix.image.ref || (matrix.image.repo == inputs.tested_repo && github.ref) || github.base_ref || github.ref_name }}
4655

4756
- name: Setup golang
4857
uses: actions/setup-go@v6
4958
with:
5059
go-version: '1.25'
5160

61+
- name: Apply go mod replaces
62+
id: go_mod_replaces
63+
shell: bash
64+
if: matrix.image.go_mod_replaces != '' && matrix.image.go_mod_replaces[0] != null
65+
env:
66+
GO_MOD_REPLACES_JSON: ${{ toJSON(matrix.image.go_mod_replaces) }}
67+
run: |
68+
GO_MOD_DIR="${{ matrix.image.go_mod_directory || '.' }}"
69+
cd "$GO_MOD_DIR"
70+
echo "Applying go mod replaces in directory: $(pwd)"
71+
72+
REPLACE_ARGS=()
73+
while IFS= read -r replace; do
74+
echo " -replace $replace"
75+
REPLACE_ARGS+=("-replace" "$replace")
76+
done < <(echo "$GO_MOD_REPLACES_JSON" | jq -r '.[]')
77+
go mod edit "${REPLACE_ARGS[@]}"
78+
5279
- name: Update go mod to the branch
5380
id: go_mod
5481
shell: bash
5582
if: matrix.image.go_mod_update != '' && matrix.image.go_mod_update[0] != null
83+
env:
84+
GO_MOD_UPDATE_JSON: ${{ toJSON(matrix.image.go_mod_update) }}
5685
run: |
5786
# Change to the specified directory if provided, otherwise use current directory
5887
GO_MOD_DIR="${{ matrix.image.go_mod_directory || '.' }}"
5988
cd "$GO_MOD_DIR"
6089
echo "Running go mod commands in directory: $(pwd)"
6190
62-
for mod_update in ${{ join(matrix.image.go_mod_update, ' ') }}
63-
do
91+
while IFS= read -r mod_update; do
6492
echo "updating go mod $mod_update"
65-
go get $mod_update
66-
done
93+
go get "$mod_update"
94+
done < <(echo "$GO_MOD_UPDATE_JSON" | jq -r '.[]')
6795
6896
# Run go mod tidy to clean up
6997
go mod tidy

.github/workflows/e2e-image-build.yaml

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,48 @@ jobs:
6565
with:
6666
python-version: '3.12'
6767

68+
- name: Get ci comments
69+
id: get_ci_comments
70+
if: github.event.pull_request.number
71+
shell: bash
72+
env:
73+
GH_TOKEN: ${{ github.token }}
74+
PR_NUMBER: ${{ github.event.pull_request.number }}
75+
REPO: ${{ github.repository }}
76+
run: |
77+
OVERRIDES=$(gh pr view "$PR_NUMBER" -R "$REPO" --json comments \
78+
| jq -c '[.comments[] | select(.body | startswith("/ci test-with")) | .body | ltrimstr("/ci test-with ")]')
79+
echo "overrides=$OVERRIDES" >> $GITHUB_OUTPUT
80+
6881
- name: Prepare matrix configs
6982
id: prepare
7083
shell: bash
84+
env:
85+
OVERRIDES: ${{ steps.get_ci_comments.outputs.overrides }}
86+
TESTED_REPO_FORK: ${{ github.event.pull_request.head.repo.full_name }}
87+
TESTED_REPO_BRANCH: ${{ github.event.pull_request.head.ref }}
88+
GH_TOKEN: ${{ github.token }}
7189
run: |
72-
90+
7391
pip install -r scripts/requirements.txt
74-
python scripts/parse_matrix_config.py .github/workflows/nightly-matrix-config.yaml -t ${{ inputs.tag || github.run_id }} -b ${{ github.base_ref || github.ref_name }} -r ${{ inputs.repo || github.repository }} out
92+
93+
cmd=(
94+
python scripts/parse_matrix_config.py
95+
.github/workflows/nightly-matrix-config.yaml
96+
-t "${{ inputs.tag || github.run_id }}"
97+
-b "${{ github.base_ref || github.ref_name }}"
98+
-r "${{ inputs.repo || github.repository }}"
99+
)
100+
101+
if [ -n "$OVERRIDES" ] && [ "$OVERRIDES" != "[]" ]; then
102+
echo "Applying CI comment overrides: $OVERRIDES"
103+
cmd+=(-o "$OVERRIDES")
104+
if [ -n "$TESTED_REPO_FORK" ] && [ -n "$TESTED_REPO_BRANCH" ]; then
105+
cmd+=(--tested-repo-head "${TESTED_REPO_FORK}:${TESTED_REPO_BRANCH}")
106+
fi
107+
fi
108+
109+
"${cmd[@]}" out
75110
76111
# The output may be one ore more of these, we should handle the case where these are empty.
77112
matrix_0=$(cat out/level_0.json)

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,51 @@ Component | CI (after merge) | Nightly (cron)
1919
**Kantra CLI** | | [![Nightly CLI test for main](https://github.com/konveyor-ecosystem/kantra-cli-tests/actions/workflows/nightly-main-latest.yaml/badge.svg)](https://github.com/konveyor-ecosystem/kantra-cli-tests/actions/workflows/nightly-main-latest.yaml)
2020

2121

22+
## NOTE About Future
23+
24+
Today all of the workflows below are deprecated, and we will be moving away from them.
25+
26+
* [global-ci.yml](.github/workflows/global-ci.yml)
27+
* [nightly-release-0.8.yaml](.github/workflows/nightly-release-0.8.yaml)
28+
* [ci-repo.yaml](.github/workflows/ci-repo.yaml)
29+
* [global-ci-bundle.yml](.github/workflows/global-ci-bundle.yml)
30+
* [nightly-main.yaml](.github/workflows/nightly-main.yaml)
31+
* [nightly-release-0.7.yaml](.github/workflows/nightly-release-0.7.yaml)
32+
* [validate-shared-tests.yml](.github/workflows/validate-shared-tests.yml)
33+
34+
These workflows are the new workflows and related files:
35+
36+
* [nightly-matrix-config.yaml](.github/workflows/nightly-matrix-config.yaml)
37+
> This is the source of truth for how repositories are tied together, what images need to be based on others.
38+
> Also contains the information for how to build the image for the given repository.
39+
40+
* [nightly-koncur](.github/workflows/nightly-koncur.yaml) and [nightly-koncur-0.9.yaml](.github/workflows/nightly-koncur-0.9.yaml)
41+
> These are used for the nightly tests, running as a cron.
42+
> This is responsible for using the [script](scripts/parse_matrix_config.py) to determine the dependency levels for image builds.
43+
> It will then run for all valid levels with the `build-nightly-images.yaml` workflow.
44+
> Once all the images are built, it will run koncur for hub and kantra.
45+
> Note: the release-0.9 version hardcodes the branch and reuses `nightly-koncur.yaml`.
46+
47+
* [build-nightly-images.yaml](.github/workflows/build-nightly-images.yaml)
48+
> This is used for building the images for a given level of image builds. It creates a matrix of the build images, that will:
49+
> * Check out the repo
50+
> * Update Go module dependencies and apply any cross-repo replacements
51+
> * Build the image using the image build action.
52+
53+
54+
These are the new e2e workflows, to potentially be re-used by repos in the organization.
55+
56+
* [e2e-image-build.yaml](.github/workflows/e2e-image-build.yaml)
57+
> This is the core re-usable way to correctly build all the images in the system that need to be rebuilt based on a PR.
58+
> Uses the nightly-matrix-config and the build-nightly-images.yaml to build the correct subset of images.
59+
60+
* [e2e-hub-koncur](.github/workflows/e2e-hub-koncur.yaml)
61+
> Uses the e2e-image-build to build the correct images and then runs the hub koncur action.
62+
63+
* [e2e-kantra-koncur](.github/workflows/e2e-kantra-koncur.yaml)
64+
> Uses the e2e-image-build to build the correct images and then runs the kantra koncur action for Linux and Windows.
65+
> Note: macOS is currently too slow to run.
66+
2267
## Using the global-ci github workflow
2368

2469
This repository is home to the [global-ci github workflow](https://github.com/konveyor/ci/tree/main/.github/workflows/global-ci.yml).

0 commit comments

Comments
 (0)