-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: reuse component builds for aggregation
- Loading branch information
1 parent
d829b16
commit 894047c
Showing
2 changed files
with
54 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,9 +11,16 @@ permissions: | |
contents: read | ||
pull-requests: read | ||
|
||
env: | ||
CTF_TYPE: tgz | ||
|
||
jobs: | ||
build-cli: | ||
name: Build CLI | ||
build: | ||
name: "Build" | ||
strategy: | ||
matrix: | ||
component: [ocmcli] | ||
# component: [ocmcli, helminstaller, helmdemo, subchartsdemo, ecrplugin] | ||
runs-on: large_runner | ||
steps: | ||
- name: Checkout | ||
|
@@ -23,7 +30,6 @@ jobs: | |
with: | ||
go-version-file: '${{ github.workspace }}/go.mod' | ||
cache: false | ||
|
||
- name: Get go environment for use with cache | ||
run: | | ||
echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV | ||
|
@@ -44,54 +50,27 @@ jobs: | |
${{ env.cache_name }}-${{ runner.os }}-go- | ||
env: | ||
cache_name: ocm-cli-latest-go-cache # needs to be the same key in the end as in the build step | ||
|
||
- name: CTF | ||
run: | | ||
cd components/ocmcli | ||
PATH=$PATH:$(go env GOPATH)/bin make ctf | ||
build-helminstaller: | ||
name: Build HelmInstaller | ||
runs-on: large_runner | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: '${{ github.workspace }}/go.mod' | ||
cache: false | ||
|
||
- name: Get go environment for use with cache | ||
run: | | ||
echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV | ||
echo "go_modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV | ||
# This step will only reuse the go mod and build cache from main made during the Build, | ||
# see push_ocm.yaml => "ocm-cli-latest" Job | ||
# This means it never caches by itself and PRs cannot cause cache pollution / thrashing | ||
# This is because we have huge storage requirements for our cache because of the mass of dependencies | ||
- name: Restore / Reuse Cache from central build | ||
id: cache-golang-restore | ||
uses: actions/cache/restore@v4 # Only Restore, not build another cache (too big) | ||
cd components/${{ matrix.component }} | ||
PATH=$PATH:$(go env GOPATH)/bin CTF_TYPE=${{ env.CTF_TYPE }} make ctf descriptor describe | ||
- name: Upload CTF on main | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
path: | | ||
${{ env.go_cache }} | ||
${{ env.go_modcache }} | ||
key: ${{ env.cache_name }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/go.mod') }} | ||
restore-keys: | | ||
${{ env.cache_name }}-${{ runner.os }}-go- | ||
env: | ||
cache_name: ocm-cli-latest-go-cache # needs to be the same key in the end as in the build step | ||
|
||
- name: CTF | ||
run: | | ||
cd components/helminstaller | ||
PATH=$PATH:$(go env GOPATH)/bin make ctf | ||
build-helmdemo: | ||
name: Build HelmDemo | ||
runs-on: large_runner | ||
compression-level: '0' # we already compress ourselves | ||
if-no-files-found: error | ||
overwrite: true | ||
retention-days: 1 | ||
name: ctf-${{ matrix.component }} | ||
path: gen/${{ matrix.component }}/ctf | ||
|
||
aggregate: | ||
name: "Aggregate Build Artifacts" | ||
runs-on: ubuntu-latest | ||
needs: build | ||
env: | ||
components: ocmcli | ||
# components: ocmcli helminstaller helmdemo subchartsdemo ecrplugin | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
@@ -100,12 +79,10 @@ jobs: | |
with: | ||
go-version-file: '${{ github.workspace }}/go.mod' | ||
cache: false | ||
|
||
- name: Get go environment for use with cache | ||
run: | | ||
echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV | ||
echo "go_modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV | ||
# This step will only reuse the go mod and build cache from main made during the Build, | ||
# see push_ocm.yaml => "ocm-cli-latest" Job | ||
# This means it never caches by itself and PRs cannot cause cache pollution / thrashing | ||
|
@@ -122,89 +99,34 @@ jobs: | |
${{ env.cache_name }}-${{ runner.os }}-go- | ||
env: | ||
cache_name: ocm-cli-latest-go-cache # needs to be the same key in the end as in the build step | ||
|
||
- name: CTF | ||
run: | | ||
cd components/helmdemo | ||
PATH=$PATH:$(go env GOPATH)/bin make ctf | ||
build-subchartsdemo: | ||
name: Build Helm SubChartsDemo | ||
runs-on: large_runner | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup Go | ||
uses: actions/setup-go@v5 | ||
- name: Download CTFs | ||
uses: actions/download-artifact@v4 | ||
with: | ||
go-version-file: '${{ github.workspace }}/go.mod' | ||
cache: false | ||
|
||
- name: Get go environment for use with cache | ||
pattern: 'ctf-*' | ||
path: gen/downloaded-ctfs | ||
- name: Move CTFs into correct directory for aggregation | ||
run: | | ||
echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV | ||
echo "go_modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV | ||
# This step will only reuse the go mod and build cache from main made during the Build, | ||
# see push_ocm.yaml => "ocm-cli-latest" Job | ||
# This means it never caches by itself and PRs cannot cause cache pollution / thrashing | ||
# This is because we have huge storage requirements for our cache because of the mass of dependencies | ||
- name: Restore / Reuse Cache from central build | ||
id: cache-golang-restore | ||
uses: actions/cache/restore@v4 # Only Restore, not build another cache (too big) | ||
with: | ||
path: | | ||
${{ env.go_cache }} | ||
${{ env.go_modcache }} | ||
key: ${{ env.cache_name }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/go.mod') }} | ||
restore-keys: | | ||
${{ env.cache_name }}-${{ runner.os }}-go- | ||
env: | ||
cache_name: ocm-cli-latest-go-cache # needs to be the same key in the end as in the build step | ||
|
||
- name: CTF | ||
IFS=" " read -a COMPONENTS <<< ${{ env.components }} | ||
for i in "${COMPONENTS[@]}"; do | ||
mkdir -p ${{ github.workspace }}/gen/${i} | ||
mv ${{ github.workspace }}/gen/downloaded-ctfs/ctf-${i} ${{ github.workspace }}/gen/${i}/ctf | ||
done | ||
- name: Create aggregated CTF | ||
run: | | ||
cd components/subchartsdemo | ||
PATH=$PATH:$(go env GOPATH)/bin make ctf | ||
build-ecrplugin: | ||
name: Build ECR Plugin | ||
runs-on: large_runner | ||
steps: | ||
- name: Self Hosted Runner Post Job Cleanup Action | ||
uses: TooMuch4U/[email protected] | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup Go | ||
uses: actions/setup-go@v5 | ||
PATH=$PATH:$(go env GOPATH)/bin CTF_TYPE=${{ env.CTF_TYPE }} COMPONENTS=${{ env.components }} make plain-ctf | ||
- name: Upload aggregated CTF | ||
# only update on main | ||
if: github.ref == 'refs/heads/main' | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
go-version-file: '${{ github.workspace }}/go.mod' | ||
cache: false | ||
|
||
- name: Get go environment for use with cache | ||
run: | | ||
echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV | ||
echo "go_modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV | ||
# This step will only reuse the go mod and build cache from main made during the Build, | ||
# see push_ocm.yaml => "ocm-cli-latest" Job | ||
# This means it never caches by itself and PRs cannot cause cache pollution / thrashing | ||
# This is because we have huge storage requirements for our cache because of the mass of dependencies | ||
- name: Restore / Reuse Cache from central build | ||
id: cache-golang-restore | ||
uses: actions/cache/restore@v4 # Only Restore, not build another cache (too big) | ||
compression-level: '0' # we already compress ourselves | ||
if-no-files-found: error | ||
overwrite: true | ||
retention-days: 1 | ||
name: ctf-aggregated | ||
path: gen/ctf | ||
- name: Delete old CTFs that lead up to aggregation | ||
uses: geekyeggo/delete-artifact@v5 | ||
with: | ||
path: | | ||
${{ env.go_cache }} | ||
${{ env.go_modcache }} | ||
key: ${{ env.cache_name }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/go.mod') }} | ||
restore-keys: | | ||
${{ env.cache_name }}-${{ runner.os }}-go- | ||
env: | ||
cache_name: ocm-cli-latest-go-cache # needs to be the same key in the end as in the build step | ||
|
||
- name: CTF | ||
run: | | ||
cd components/ecrplugin | ||
PATH=$PATH:$(go env GOPATH)/bin make ctf | ||
name: | | ||
ctf-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters