Skip to content

Commit

Permalink
attempt to parrellize GHA CI
Browse files Browse the repository at this point in the history
  • Loading branch information
CamJN committed Jul 16, 2024
1 parent 5da14be commit deb4a34
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 20 deletions.
58 changes: 40 additions & 18 deletions .github/workflows/dockerimage-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 }}
Expand All @@ -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 }}
Expand Down
44 changes: 42 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit deb4a34

Please sign in to comment.