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

Update CI #77

Merged
merged 2 commits into from
Oct 25, 2023
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
39 changes: 31 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,63 @@ permissions:
pull-requests: read
jobs:
lint:
name: pull-kapacity-golangci-lint
name: Run linting
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v39
with:
files_yaml: |
go:
- '**/*.go'
- name: Set up Go
if: steps.changed-files.outputs.go_any_changed == 'true'
uses: actions/setup-go@v4
with:
go-version: "1.19"
cache: false
- name: Checkout code
uses: actions/checkout@v3
- name: Run golangci-lint
if: steps.changed-files.outputs.go_any_changed == 'true'
uses: golangci/golangci-lint-action@v3
with:
version: latest
only-new-issues: true
# TODO(zqzten): add verify job
test:
name: pull-kapacity-unit-test
name: Run unit tests
needs: lint
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.19"
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v39
with:
files_yaml: |
go:
- '**/*.go'
- go.mod
- go.sum
- Makefile
- name: Git config
if: steps.changed-files.outputs.go_any_modified == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Rebase code
if: steps.changed-files.outputs.go_any_modified == 'true'
run: git rebase origin/main
- name: Set up Go
if: steps.changed-files.outputs.go_any_modified == 'true'
uses: actions/setup-go@v4
with:
go-version: "1.19"
- name: Run unit tests
if: steps.changed-files.outputs.go_any_modified == 'true'
run: make unit-test
37 changes: 37 additions & 0 deletions .github/workflows/release-algorithm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Release
on:
push:
tags:
- 'algorithm-v*'
permissions:
contents: read
packages: write
jobs:
build-and-push-image:
name: Build and push image
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get tag
run: echo "tag=$(git describe --tags --match 'algorithm-v*' | sed -e 's/^algorithm-//')" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push image
uses: docker/build-push-action@v4
with:
context: ./algorithm
file: ./algorithm/horizontal-predictive.Dockerfile
platforms: linux/amd64
push: true
tags: ghcr.io/${{ github.repository_owner }}/kapacity-algorithm-horizontal-predictive:${{ env.tag }}
6 changes: 3 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ permissions:
contents: read
packages: write
jobs:
image:
name: build-and-push-kapacity-manager-image
build-and-push-image:
name: Build and push image
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get tag
run: echo "tag=$(git describe --tags)" >> $GITHUB_ENV
run: echo "tag=$(git describe --tags --match 'v*')" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
Expand Down