From deb4a34930fbda26bac53e6e5794d3946c29825e Mon Sep 17 00:00:00 2001 From: Camden Narzt Date: Tue, 16 Jul 2024 11:02:46 -0600 Subject: [PATCH] attempt to parrellize GHA CI --- .github/workflows/dockerimage-ci.yml | 58 +++++++++++++++++++--------- Makefile | 44 ++++++++++++++++++++- 2 files changed, 82 insertions(+), 20 deletions(-) diff --git a/.github/workflows/dockerimage-ci.yml b/.github/workflows/dockerimage-ci.yml index 2c7a180..9696d48 100644 --- a/.github/workflows/dockerimage-ci.yml +++ b/.github/workflows/dockerimage-ci.yml @@ -18,14 +18,15 @@ on: branches: - master - fork/master + - el8_migration jobs: code_check: name: Code checks runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2 - - uses: ludeeus/action-shellcheck@94e0aab03ca135d11a35e5bfc14e6746dc56e7e9 + - uses: actions/checkout@v4 + - uses: ludeeus/action-shellcheck@2 env: SHELLCHECK_OPTS: -x - name: Install eclint @@ -37,11 +38,18 @@ jobs: name: "Test Build Docker images" if: github.event_name == 'pull_request' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest + strategy: + matrix: + arch: + - 'amd64' + - 'arm64' + env: + BUILD_AMD64: ${{ fromJSON('[0, 1]')[matrix.arch == 'amd64'] }} + BUILD_ARM64: ${{ fromJSON('[0, 1]')[matrix.arch == 'arm64'] }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set lower case repository owner name - run: | - echo "OWNER_LC=${OWNER,,}" >>"$GITHUB_ENV" + run: echo "OWNER_LC=${OWNER,,}" >> "$GITHUB_ENV" env: OWNER: '${{ github.repository_owner }}' - name: Build the Docker images @@ -51,15 +59,22 @@ jobs: name: "Build edge Docker images" if: github.event_name != 'create' && github.event_name != 'pull_request' && github.event_name != 'schedule' runs-on: ubuntu-latest + strategy: + matrix: + arch: + - 'amd64' + - 'arm64' + env: + BUILD_AMD64: ${{ fromJSON('[0, 1]')[matrix.arch == 'amd64'] }} + BUILD_ARM64: ${{ fromJSON('[0, 1]')[matrix.arch == 'arm64'] }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set lower case repository owner name - run: | - echo "OWNER_LC=${OWNER,,}" >>"$GITHUB_ENV" + run: echo "OWNER_LC=${OWNER,,}" >> "$GITHUB_ENV" env: OWNER: '${{ github.repository_owner }}' - name: Log in to the Container registry - uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} @@ -73,25 +88,32 @@ jobs: name: "Build release Docker images" if: github.event_name == 'create' && github.event.ref_type == 'tag' runs-on: ubuntu-latest + strategy: + matrix: + arch: + - 'amd64' + - 'arm64' + env: + BUILD_AMD64: ${{ fromJSON('[0, 1]')[matrix.arch == 'amd64'] }} + BUILD_ARM64: ${{ fromJSON('[0, 1]')[matrix.arch == 'arm64'] }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set lower case repository owner name - run: | - echo "OWNER_LC=${OWNER,,}" >>"$GITHUB_ENV" + run: echo "OWNER_LC=${OWNER,,}" >> "$GITHUB_ENV" env: OWNER: '${{ github.repository_owner }}' - - name: Check tag + - name: Check versions match (Makefile & git-tag) run: | - VERSION1=$(grep '^VERSION = ' Makefile | sed 's|.*= *||') - VERSION2=$(sed 's|^rel-||' <<< "$TAG") - if [[ "$VERSION1" != "$VERSION2" ]]; then - echo "ERROR: version in Makefile ($VERSION1) doesn't match Git tag ($VERSION2)" + MAKEFILE_VERSION=$(grep '^VERSION = ' Makefile | sed 's|.*= *||') + GIT_TAG_VERSION=$(sed 's|^rel-||' <<< "$TAG") + if [[ "MAKEFILE_$VERSION" != "$GIT_TAG_VERSION" ]]; then + echo "ERROR: version in Makefile ($MAKEFILE_VERSION) doesn't match Git tag ($GIT_TAG_VERSION)" exit 1 fi env: TAG: ${{ github.event.ref }} - name: Log in to the Container registry - uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} diff --git a/Makefile b/Makefile index cbe984f..4421c50 100644 --- a/Makefile +++ b/Makefile @@ -8,31 +8,71 @@ IMAGE = $(OWNER)/holy-build-box .PHONY: build test tags push release +ifeq (${BUILD_AMD64},0) +_build_amd64 := 0 +else +_build_amd64 := 1 +endif + +ifeq (${BUILD_ARM64},0) +_build_arm64 := 0 +else +_build_arm64 := 1 +endif + build: +ifeq ($(_build_amd64),1) docker buildx build --platform "linux/amd64" --rm -t $(IMAGE)-amd64:$(VERSION) --pull --build-arg DISABLE_OPTIMIZATIONS=$(DISABLE_OPTIMIZATIONS) . +endif +ifeq ($(_build_arm64),1) docker buildx build --platform "linux/arm64" --rm -t $(IMAGE)-arm64:$(VERSION) --pull --build-arg DISABLE_OPTIMIZATIONS=$(DISABLE_OPTIMIZATIONS) . +endif test: +ifeq ($(_build_amd64),1) docker run -it --platform "linux/amd64" --rm -e SKIP_FINALIZE=1 -e DISABLE_OPTIMIZATIONS=1 -v $$(pwd)/image:/hbb_build:ro rockylinux:8 bash /hbb_build/build.sh +endif +ifeq ($(_build_arm64),1) docker run -it --platform "linux/arm64" --rm -e SKIP_FINALIZE=1 -e DISABLE_OPTIMIZATIONS=1 -v $$(pwd)/image:/hbb_build:ro rockylinux:8 bash /hbb_build/build.sh +endif tags: ifdef MAJOR_VERSION - docker tag $(IMAGE):$(VERSION)-arm64 $(IMAGE):$(MAJOR_VERSION)-arm64 +ifeq ($(_build_amd64),1) docker tag $(IMAGE):$(VERSION)-amd64 $(IMAGE):$(MAJOR_VERSION)-amd64 - docker tag $(IMAGE):$(VERSION)-arm64 $(IMAGE):latest-arm64 +endif +ifeq ($(_build_arm64),1) + docker tag $(IMAGE):$(VERSION)-arm64 $(IMAGE):$(MAJOR_VERSION)-arm64 +endif +ifeq ($(_build_amd64),1) docker tag $(IMAGE):$(VERSION)-amd64 $(IMAGE):latest-amd64 endif +ifeq ($(_build_arm64),1) + docker tag $(IMAGE):$(VERSION)-arm64 $(IMAGE):latest-arm64 +endif +endif push: tags +ifeq ($(_build_amd64),1) docker push $(IMAGE):$(VERSION)-amd64 +endif +ifeq ($(_build_arm64),1) docker push $(IMAGE):$(VERSION)-arm64 +endif ifdef MAJOR_VERSION +ifeq ($(_build_amd64),1) docker push $(IMAGE):$(MAJOR_VERSION)-amd64 +endif +ifeq ($(_build_arm64),1) docker push $(IMAGE):$(MAJOR_VERSION)-arm64 +endif +ifeq ($(_build_amd64),1) docker push $(IMAGE):latest-amd64 +endif +ifeq ($(_build_arm64),1) docker push $(IMAGE):latest-arm64 endif +endif release: push docker manifest create $(IMAGE):$(VERSION) $(IMAGE):$(VERSION)-amd64 $(IMAGE):$(VERSION)-arm64