Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: unify github actions workflow using multiarch image of build-tools #3131

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 43 additions & 105 deletions .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,78 +3,30 @@ on:
- pull_request
jobs:
validate:
name: Validate PR
runs-on: ubuntu-latest
container: ubuntu:focal
name: validate - ${{ matrix.name }}
runs-on: ${{ matrix.runner }}
container: ghcr.io/kedacore/build-tools:main
strategy:
matrix:
include:
- runner: ARM64
name: arm64
- runner: ubuntu-latest
name: amd64
steps:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.17

- name: Install necessary packages
run: apt update && apt install -y make ca-certificates gcc

- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: Set Go paths
id: go-paths
run: |
echo ::set-output name=mod_cache::$(go env GOMODCACHE)
echo ::set-output name=build_cache::$(go env GOCACHE)

- name: Go modules cache
uses: actions/cache@v3.0.5
with:
path: ${{ steps.go-paths.outputs.mod_cache }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}

- name: Go build cache
uses: actions/cache@v3.0.5
with:
path: ${{ steps.go-paths.outputs.build_cache }}
key: ${{ runner.os }}-go-build-cache-${{ hashFiles('**/go.sum') }}

- name: Go modules sync
run: go mod tidy

- name: Verify Generated clientset is up to date
run: make clientset-verify

- name: Build
run: make build

- name: Test
run: make test

- name: Create test Summary
uses: test-summary/action@v1
with:
paths: "report.xml"
if: always()

validate-arm64:
name: Validate PR on ARM64
runs-on: ARM64
container: arm64v8/ubuntu:focal
env:
ARCH: arm64
steps:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.17

- name: Install necessary packages
run: apt update && apt install -y make ca-certificates gcc
# Enable this if you need a different version that the already installed in build-tools image
# - uses: actions/setup-go@v3
# with:
# go-version: 1.18

- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Check go version
run: go version

- name: Set Go paths
id: go-paths
Expand Down Expand Up @@ -113,9 +65,16 @@ jobs:
if: always()

validate-dockerfiles:
name: Validate Dockerfiles
runs-on: ubuntu-latest
name: validate-dockerfiles - ${{ matrix.name }}
runs-on: ${{ matrix.runner }}
container: ghcr.io/kedacore/build-tools:main
strategy:
matrix:
include:
- runner: ARM64
name: arm64
- runner: ubuntu-latest
name: amd64
steps:
- name: Check out code
uses: actions/checkout@v3
Expand All @@ -134,9 +93,16 @@ jobs:
run: make docker-build

validate-build-tools:
name: Validate build-tools
runs-on: ubuntu-latest
name: Validate build-tools - ${{ matrix.name }}
runs-on: ${{ matrix.runner }}
container: ghcr.io/kedacore/build-tools:main
strategy:
matrix:
include:
- runner: ARM64
name: arm64
- runner: ubuntu-latest
name: amd64
steps:
- uses: actions/checkout@v3

Expand All @@ -160,9 +126,16 @@ jobs:
run: make docker-build-tools

validate-dev-container:
name: Validate dev-container
runs-on: ubuntu-latest
name: Validate dev-container - ${{ matrix.name }}
runs-on: ${{ matrix.runner }}
container: ghcr.io/kedacore/build-tools:main
strategy:
matrix:
include:
- runner: ARM64
name: arm64
- runner: ubuntu-latest
name: amd64
steps:
- uses: actions/checkout@v3

Expand All @@ -177,41 +150,6 @@ jobs:
if: steps.filter.outputs.devcontainer == 'true'
run: make docker-build-dev-containers

validate-dev-container-arm64:
name: Validate dev-container on ARM64
runs-on: ARM64
container: arm64v8/ubuntu:focal
env:
DEBIAN_FRONTEND: noninteractive
steps:
- uses: actions/checkout@v3

- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
devcontainer:
- '.devcontainer/Dockerfile'

- name: Setup Go
if: steps.filter.outputs.devcontainer == 'true'
uses: actions/setup-go@v3
with:
go-version: 1.17

- name: Install deps
if: steps.filter.outputs.devcontainer == 'true'
run: |
apt update && apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common lsb-release make
curl -fsSL https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/gpg | apt-key add - 2>/dev/null
add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]') $(lsb_release -cs) stable"
apt-get update
apt-get install -y docker-ce-cli

- name: Build tools
if: steps.filter.outputs.devcontainer == 'true'
run: make docker-build-dev-containers

statics:
name: Static Checks
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@ help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

.PHONY: docker-build-tools
docker-build-tools: ## Build multi-arch Docker image for build-tools.
docker buildx build --platform=${BUILD_PLATFORMS} -f tools/build-tools.Dockerfile -t ${IMAGE_BUILD_TOOLS} .
docker-build-tools: ## Build build-tools image
docker build -f tools/build-tools.Dockerfile -t $(IMAGE_BUILD_TOOLS) .

.PHONY: publish-build-tools
publish-build-tools: ## Build and push multi-arch Docker image for build-tools.
Expand Down