Skip to content

Commit

Permalink
Merge pull request eksctl-io#7551 from yuxiang-zhang/extract-setup-build
Browse files Browse the repository at this point in the history
Extract common workflow steps to set up build environment
  • Loading branch information
yuxiang-zhang authored Feb 14, 2024
2 parents 647874e + f5c0a54 commit d07f0c3
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 161 deletions.
25 changes: 25 additions & 0 deletions .github/actions/setup-build/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: "Setup build"
description: "Setup environment for the build"
inputs: {}
outputs: {}
runs:
using: "composite"
steps:
- name: Setup Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 #v5.0.0
with:
go-version: 1.20.x
cache: false
- name: Cache go-build and mod
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 #v4.0.0
with:
path: |
~/.cache/go-build/
~/go/pkg/mod/
key: go-${{ hashFiles('go.sum') }}
restore-keys: |
go-
- name: Setup deps
shell: bash
run: |
make install-build-deps
26 changes: 2 additions & 24 deletions .github/workflows/build-all-distros-nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,33 +31,11 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 #v5.0.0
with:
go-version: 1.20.x
cache: false
- name: Cache go-build and mod
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 #v3.3.2
with:
path: |
~/.cache/go-build/
~/go/pkg/mod/
key: ${{ hashFiles('go.sum') }}
- name: Setup deps
run: |
make install-build-deps
- name: Setup build environment
uses: ./.github/actions/setup-build
- name: build image
run: |
EKSCTL_IMAGE_VERSION=${GITHUB_REF#refs/*/} make -f Makefile.docker eksctl-image
- name: build all
run: |
make build-all
- name: slack on failure
if: failure()
uses: actions-ecosystem/action-slack-notifier@fc778468d09c43a6f4d1b8cccaca59766656996a #v1.1.0
with:
slack_token: ${{ secrets.WEAVEWORKS_SLACK_EKSCTLBOT_TOKEN }}
message: ":ahhhhhhhhh: build-all-distros has failed"
channel: team-pitch-black
color: red
verbose: true
2 changes: 1 addition & 1 deletion .github/workflows/cache-dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Cache Go modules
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 #v3.3.2
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 #v4.0.0
with:
path: |
~/.cache/go-build/
Expand Down
27 changes: 6 additions & 21 deletions .github/workflows/ecr-publish-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ jobs:
name: Build and push container image
runs-on: ubuntu-latest
steps:
- name: Checkout repo
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
with:
fetch-depth: 0

- name: Setup build environment
uses: ./.github/actions/setup-build

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@010d0da01d0b5a38af31e9c3470dbfdabdecca3a # v4.0.1
Expand All @@ -28,26 +33,6 @@ jobs:
with:
registry-type: public

- name: Setup Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 #v5.0.0
with:
go-version: 1.20.x
cache: false

- name: Cache go-build and mod
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 #v3.3.2
with:
path: |
~/.cache/go-build/
~/go/pkg/mod/
key: go-${{ hashFiles('go.sum') }}
restore-keys: |
go-
- name: Setup deps
run: |
make install-build-deps
- name: Build and push image
run: |
PATH=$PATH:$(go env GOPATH)/bin make -f Makefile.docker push-build-image
36 changes: 3 additions & 33 deletions .github/workflows/publish-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,11 @@ jobs:
with:
token: ${{ secrets.EKSCTLBOT_TOKEN }}
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 #v5.0.0
with:
go-version: 1.20.x
cache: false
- name: Cache go-build and mod
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 #v3.3.2
with:
path: |
~/.cache/go-build/
~/go/pkg/mod/
key: go-${{ hashFiles('go.sum') }}
restore-keys: |
go-
- name: Setup build environment
uses: ./.github/actions/setup-build
- name: Setup identity as eksctl-bot
uses: ./.github/actions/setup-identity
with:
token: "${{ secrets.EKSCTLBOT_TOKEN }}"
- name: Trigger Netlify deployment
run: make publish-docs
- name: slack on success
if: success()
uses: actions-ecosystem/action-slack-notifier@fc778468d09c43a6f4d1b8cccaca59766656996a #v1.1.0
with:
slack_token: ${{ secrets.WEAVEWORKS_SLACK_EKSCTLBOT_TOKEN }}
message: ":tada: Docs published successfully :tada:"
channel: team-pitch-black
color: green
verbose: true
- name: slack on failure
if: failure()
uses: actions-ecosystem/action-slack-notifier@fc778468d09c43a6f4d1b8cccaca59766656996a #v1.1.0
with:
slack_token: ${{ secrets.WEAVEWORKS_SLACK_EKSCTLBOT_TOKEN }}
message: ":ahhhhhhhhh: Docs publishing failed."
channel: team-pitch-black
color: red
verbose: true
run: make publish-docs
29 changes: 1 addition & 28 deletions .github/workflows/publish-release-type.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
go-version: 1.20.x
cache: false
- name: Cache go-build and mod
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 #v3.3.2
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 #v4.0.0
with:
path: |
~/.cache/go-build/
Expand All @@ -61,30 +61,3 @@ jobs:
- name: get version
id: get_version
run: echo "version=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: slack on success - team-pitch-black
if: ${{ success() }}
uses: actions-ecosystem/action-slack-notifier@fc778468d09c43a6f4d1b8cccaca59766656996a #v1.1.0
with:
slack_token: ${{ secrets.slackToken }}
message: ":cool-doge: ${{ inputs.name }} successful for tag <https://github.com/eksctl-io/eksctl/releases/tag/${{ steps.get_version.outputs.version }}|${{ steps.get_version.outputs.version }}>"
channel: team-pitch-black
color: green
verbose: false
- name: slack on failure - team-pitch-black
if: ${{ failure() }}
uses: actions-ecosystem/action-slack-notifier@fc778468d09c43a6f4d1b8cccaca59766656996a #v1.1.0
with:
slack_token: ${{ secrets.slackToken }}
message: ":ahhhhhhhhh: ${{ inputs.name }} has failed for tag <https://github.com/eksctl-io/eksctl/releases/tag/${{ steps.get_version.outputs.version }}|${{ steps.get_version.outputs.version }}>"
channel: team-pitch-black
color: red
verbose: true
- name: slack on success - aws-dev
if: ${{ success() }}
uses: actions-ecosystem/action-slack-notifier@fc778468d09c43a6f4d1b8cccaca59766656996a #v1.1.0
with:
slack_token: ${{ secrets.slackToken }}
message: ":tada: <https://github.com/eksctl-io/eksctl/releases/tag/${{ steps.get_version.outputs.version }}|${{ steps.get_version.outputs.version }}> released!"
channel: aws-dev
color: green
verbose: false
2 changes: 1 addition & 1 deletion .github/workflows/release-candidate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
token: ${{ secrets.EKSCTLBOT_TOKEN }}
fetch-depth: 0
- name: Cache go-build and mod
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 #v3.3.2
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 #v4.0.0
with:
path: |
~/.cache/go-build/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
token: ${{ secrets.EKSCTLBOT_TOKEN }}
fetch-depth: 0
- name: Cache go-build and mod
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 #v3.3.2
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 #v4.0.0
with:
path: |
~/.cache/go-build/
Expand Down
57 changes: 6 additions & 51 deletions .github/workflows/test-and-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,8 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 #v5.0.0
with:
go-version: 1.20.x
cache: false
- name: Cache go-build and mod
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 #v3.3.2
with:
path: |
~/.cache/go-build/
~/go/pkg/mod/
key: go-${{ hashFiles('go.sum') }}
restore-keys: |
go-
- name: Setup deps
run: |
make install-build-deps
- name: Setup build environment
uses: ./.github/actions/setup-build
- name: Unit test
run: |
PATH=$PATH:$(go env GOPATH)/bin make build
Expand All @@ -42,23 +27,8 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 #v5.0.0
with:
go-version: 1.20.x
cache: false
- name: Cache go-build and mod
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 #v3.3.2
with:
path: |
~/.cache/go-build/
~/go/pkg/mod/
key: go-${{ hashFiles('go.sum') }}
restore-keys: |
go-
- name: Setup deps
run: |
make install-build-deps
- name: Setup build environment
uses: ./.github/actions/setup-build
- name: Lint
run: |
PATH=$PATH:$(go env GOPATH)/bin make lint
Expand All @@ -70,23 +40,8 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 #v5.0.0
with:
go-version: 1.20.x
cache: false
- name: Cache go-build and mod
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 #v3.3.2
with:
path: |
~/.cache/go-build/
~/go/pkg/mod/
key: go-${{ hashFiles('go.sum') }}
restore-keys: |
go-
- name: Setup deps
run: |
make install-build-deps
- name: Setup build environment
uses: ./.github/actions/setup-build
- name: build
run: |
PATH=$PATH:$(go env GOPATH)/bin make -f Makefile.docker check-build-image-manifest-up-to-date
2 changes: 1 addition & 1 deletion .github/workflows/update-generated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
with:
token: "${{ secrets.EKSCTLBOT_TOKEN }}"
- name: Cache go-build and mod
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 #v3.3.2
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 #v4.0.0
with:
path: |
~/.cache/go-build/
Expand Down

0 comments on commit d07f0c3

Please sign in to comment.