Skip to content

Commit

Permalink
chore: reuse component builds for aggregation
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobmoellerdev committed Nov 4, 2024
1 parent 894047c commit 1b9db60
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
17 changes: 11 additions & 6 deletions .github/workflows/components.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
# component: [ocmcli, helminstaller, helmdemo, subchartsdemo, ecrplugin]
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
Expand Down Expand Up @@ -54,24 +56,26 @@ jobs:
run: |
cd components/${{ matrix.component }}
PATH=$PATH:$(go env GOPATH)/bin CTF_TYPE=${{ env.CTF_TYPE }} make ctf descriptor describe
- name: Upload CTF on main
- name: Upload CTF
uses: actions/upload-artifact@v4
with:
compression-level: '0' # we already compress ourselves
if-no-files-found: error
overwrite: true
retention-days: 1
name: ctf-${{ matrix.component }}
name: ctf-component-${{ matrix.component }}
path: gen/${{ matrix.component }}/ctf

aggregate:
name: "Aggregate Build Artifacts"
runs-on: ubuntu-latest
runs-on: large_runner
needs: build
env:
components: ocmcli
# components: ocmcli helminstaller helmdemo subchartsdemo ecrplugin
steps:
- name: Self Hosted Runner Post Job Cleanup Action
uses: TooMuch4U/[email protected]
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
Expand Down Expand Up @@ -102,14 +106,15 @@ jobs:
- name: Download CTFs
uses: actions/download-artifact@v4
with:
pattern: 'ctf-*'
pattern: 'ctf-component-*'
path: gen/downloaded-ctfs
- name: Move CTFs into correct directory for aggregation
run: |
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
unzip ${{ github.workspace }}/gen/downloaded-ctfs/ctf-component-${i} ctf ${{ github.workspace }}/gen/${i}
ls -R ${{ github.workspace }}/gen/${i}
done
- name: Create aggregated CTF
run: |
Expand All @@ -129,4 +134,4 @@ jobs:
uses: geekyeggo/delete-artifact@v5
with:
name: |
ctf-*
ctf-component-*
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
PLATFORMS = windows/amd64 darwin/arm64 darwin/amd64 linux/amd64 linux/arm64

CREDS ?=
OCM := go run $(REPO_ROOT)/cmds/ocm $(CREDS)
OCM := bin/ocm $(CREDS)
CTF_TYPE ?= directory

GEN := $(REPO_ROOT)/gen
Expand Down Expand Up @@ -165,7 +165,7 @@ $(GEN)/.comps: $(GEN)/.exists
.PHONY: ctf
ctf: $(GEN)/ctf

$(GEN)/ctf: $(GEN)/.exists $(GEN)/.comps
$(GEN)/ctf: $(GEN)/.exists $(GEN)/.comps bin/ocm
@rm -rf "$(GEN)"/ctf
@for i in $(COMPONENTS); do \
echo "transfering component $$i..."; \
Expand All @@ -177,16 +177,16 @@ $(GEN)/ctf: $(GEN)/.exists $(GEN)/.comps
.PHONY: push
push: $(GEN)/ctf $(GEN)/.push.$(NAME)

$(GEN)/.push.$(NAME): $(GEN)/ctf
$(GEN)/.push.$(NAME): $(GEN)/ctf bin/ocm
$(OCM) transfer ctf -f $(GEN)/ctf $(OCMREPO)
@touch $@

.PHONY: plain-push
plain-push: $(GEN)
plain-push: $(GEN) bin/ocm
$(OCM) transfer ctf -f $(GEN)/ctf $(OCMREPO)

.PHONY: plain-ctf
plain-ctf: $(GEN)
plain-ctf: $(GEN) bin/ocm
@rm -rf "$(GEN)"/ctf
@for i in $(COMPONENTS); do \
echo "transfering component $$i..."; \
Expand Down

0 comments on commit 1b9db60

Please sign in to comment.