Skip to content

Commit

Permalink
Merge pull request #77 from zqzten/ci
Browse files Browse the repository at this point in the history
Update CI
  • Loading branch information
dayko2019 authored Oct 25, 2023
2 parents 9acccca + e1807bd commit 5f79ba3
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 11 deletions.
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

0 comments on commit 5f79ba3

Please sign in to comment.