Merge pull request #258 from chengxiangdong/workflow #662
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI Workflow | |
on: | |
# Run this workflow every time a new commit pushed to upstream/fork repository. | |
# Run workflow on fork repository will help contributors find and resolve issues before sending a PR. | |
push: | |
pull_request: | |
jobs: | |
golangci: | |
name: lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install Go | |
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0 | |
with: | |
go-version: '>=1.22' | |
check-latest: true | |
- name: Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Check vendors | |
run: hack/verify-vendor.sh | |
- name: Check gofmt | |
run: hack/verify-gofmt.sh | |
- name: Check static code | |
run: hack/verify-staticcheck.sh | |
build: | |
name: compile | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
# Number of commits to fetch. 0 indicates all history for all branches and tags. | |
# We need to guess version via git tags. | |
fetch-depth: 0 | |
- name: Install Go | |
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0 | |
with: | |
go-version: '>=1.22' | |
check-latest: true | |
- name: compile | |
run: make all | |
test: | |
name: unit test | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Install Go | |
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0 | |
with: | |
go-version: '>=1.22' | |
- name: make test | |
run: make test | |
e2e: | |
# This job does not run on forked repositories because there is no self-runner. | |
if: ${{ github.repository == 'kubernetes-sigs/cloud-provider-huaweicloud' }} | |
name: e2e test | |
needs: build | |
runs-on: self-hosted | |
strategy: | |
max-parallel: 1 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
fetch-depth: 0 | |
- name: Install Go | |
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0 | |
with: | |
go-version: '>=1.22' | |
- name: run e2e | |
run: | | |
export ARTIFACTS_PATH=${{ github.workspace }}/e2e-logs | |
./hack/run-e2e.sh | |
- name: upload logs | |
if: always() | |
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 | |
with: | |
name: e2e_log | |
path: ${{ github.workspace }}/e2e-logs/ |