apis: add Recommendation crd (#1937) #2
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 | |
on: | |
push: | |
branches: | |
- main | |
- release-* | |
pull_request: { } | |
workflow_dispatch: { } | |
jobs: | |
golangci-lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
cache: false | |
go-version-file: go.mod | |
- run: sudo apt update && sudo apt install -y libpfm4 libpfm4-dev | |
- uses: golangci/golangci-lint-action@v3 | |
with: | |
version: v1.47.3 | |
unit-tests: | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- step: mod | |
name: Check Go modules | |
command: go mod tidy && git add go.* && git diff --cached --exit-code || (echo 'Please run "go mod tidy" to sync Go modules' && exit 1); | |
- step: manifests | |
name: Check manifests | |
command: make manifests && git add config && git diff --cached --exit-code || (echo 'Please run "make manifests" to generate manifests' && exit 1); | |
- step: generate | |
name: Check auto-generated codes | |
command: make generate && git add pkg apis && git diff --cached --exit-code || (echo 'Please run "make generate" to generate Go codes' && exit 1); | |
- step: gofmt | |
name: Verify gofmt | |
command: make fmt && git add apis pkg cmd && git diff --cached --exit-code || (echo 'Please run "make fmt" to verify gofmt' && exit 1); | |
- step: govet | |
name: Verify govet | |
command: make vet && git add apis pkg cmd && git diff --cached --exit-code || (echo 'Please run "make vet" to verify govet' && exit 1); | |
- step: build | |
name: Run Go build | |
command: make build | |
- step: test | |
name: Run Go test | |
command: make fast-test | |
name: unit-tests(${{ matrix.name }}) | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
cache: false | |
go-version-file: go.mod | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cache/go-build | |
~/go/pkg/mod | |
key: ${{ runner.os }}-ut-${{ matrix.step }}-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-ut-${{ matrix.step }}- | |
- name: ${{ matrix.name }} | |
run: | | |
sudo apt update && sudo apt install -y libpfm4 libpfm4-dev | |
${{ matrix.command }} | |
- if: matrix.step == 'test' | |
name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
flags: unittests | |
file: cover.out | |
fail_ci_if_error: true | |
build-and-push: | |
needs: [ golangci-lint, unit-tests ] | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
target: [ koordlet, koord-manager, koord-scheduler, koord-descheduler ] | |
env: | |
GITHUB_REG: ghcr.io | |
ALIYUN_BJ_REG: registry.cn-beijing.aliyuncs.com | |
ALIYUN_HZ_REG: registry.cn-hangzhou.aliyuncs.com | |
steps: | |
- uses: docker/setup-buildx-action@v3 | |
- name: Login to GHCR | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.GITHUB_REG }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build the image | |
uses: docker/build-push-action@v5 | |
with: | |
platforms: linux/amd64 | |
push: false | |
pull: true | |
file: docker/${{ matrix.target }}.dockerfile | |
labels: | | |
org.opencontainers.image.title=${{ matrix.target }} | |
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} | |
org.opencontainers.image.revision=${{ github.sha }} | |
org.opencontainers.image.created=${{ github.event.repository.updated_at}} | |
org.opencontainers.image.licenses=Apache-2.0 | |
tags: | | |
${{ env.GITHUB_REG }}/${{ github.repository_owner }}/${{ matrix.target }}:${{ github.sha }} | |
cache-from: type=gha,scope=build-${{ matrix.target }} | |
cache-to: type=gha,mode=max,scope=build-${{ matrix.target }} | |
- if: github.ref == 'refs/heads/main' | |
name: Login to AliyunCS_BJ | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.ALIYUN_BJ_REG }} | |
username: ${{ secrets.ALIYUN_USERNAME }} | |
password: ${{ secrets.ALIYUN_PWD }} | |
- if: github.ref == 'refs/heads/main' | |
name: Login to AliyunCS_HZ | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.ALIYUN_HZ_REG }} | |
username: ${{ secrets.ALIYUN_USERNAME }} | |
password: ${{ secrets.ALIYUN_PWD }} | |
- if: github.ref == 'refs/heads/main' | |
name: Build and push the multi-arch images | |
uses: docker/build-push-action@v5 | |
with: | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
pull: true | |
file: docker/${{ matrix.target }}.dockerfile | |
labels: | | |
org.opencontainers.image.title=${{ matrix.target }} | |
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} | |
org.opencontainers.image.revision=${{ github.sha }} | |
org.opencontainers.image.created=${{ github.event.repository.updated_at}} | |
org.opencontainers.image.licenses=Apache-2.0 | |
tags: | | |
${{ env.GITHUB_REG }}/${{ github.repository_owner }}/${{ matrix.target }}:latest | |
${{ env.GITHUB_REG }}/${{ github.repository_owner }}/${{ matrix.target }}:${{ github.sha }} | |
${{ env.ALIYUN_BJ_REG }}/${{ github.repository_owner }}/${{ matrix.target }}:latest | |
${{ env.ALIYUN_BJ_REG }}/${{ github.repository_owner }}/${{ matrix.target }}:${{ github.sha }} | |
${{ env.ALIYUN_HZ_REG }}/${{ github.repository_owner }}/${{ matrix.target }}:latest | |
${{ env.ALIYUN_HZ_REG }}/${{ github.repository_owner }}/${{ matrix.target }}:${{ github.sha }} | |
cache-from: type=gha,scope=build-${{ matrix.target }} | |
cache-to: type=gha,mode=max,scope=build-${{ matrix.target }} |