Skip to content

Commit

Permalink
CI: adjust build steps
Browse files Browse the repository at this point in the history
  • Loading branch information
nixargh committed Sep 6, 2024
1 parent e76abe3 commit dc40be5
Showing 1 changed file with 52 additions and 17 deletions.
69 changes: 52 additions & 17 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,37 @@
---
name: CI

on: [push, pull_request]
on:
- push
- pull_request

jobs:
check:
name: Check
runs-on: ubuntu-latest
# Execute the checks inside the container instead the VM.
container: golangci/golangci-lint:v1.60.3
steps:
- uses: actions/checkout@v4

- name: 'Remove .git directory (fix for "error obtaining VCS status: exit status 128")'
run: rm -fr ./.git
- run: golangci-lint run -v

- name: Run GolangCI linters
run: golangci-lint run -v

unit-test:
name: Unit test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- run: make ci-test

- name: Run Unit tests
run: make ci-test

- uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_UPLOAD_TOKEN }}
Expand All @@ -35,26 +43,29 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Execute tests

- name: Execute Helm tests
env:
HELM_VERSION: v3.6.3
run: |
# Get dependencies.
echo "Getting dependencies..."
curl -L https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz | tar -xz && mv ./linux-amd64/helm /usr/local/bin && chmod +x /usr/local/bin/helm
make ci-helm-test
run:
- echo "Getting dependencies..."
- curl -L https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz | tar -xz && mv ./linux-amd64/helm /usr/local/bin && chmod +x /usr/local/bin/helm
- make ci-helm-test

integration-test-cli:
name: Integration test CLI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: Execute tests
run: |
# Build binary.
Expand All @@ -74,13 +85,21 @@ jobs:
name: Tagged release binaries
runs-on: ubuntu-latest
steps:
- run: echo "VERSION=${GITHUB_REF#refs/*/}" >> ${GITHUB_ENV} # Sets VERSION env var.
- uses: actions/checkout@v4

- name: Extract tag
shell: bash
run: echo "tag=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/tags/}}" >> $GITHUB_OUTPUT
id: extract_tag

- name: Build binaries
run: |
mkdir -p ./bin
chmod -R 0777 ./bin
make build-all
env:
VERSION: "${{ steps.extract_tag.outputs.tag }}"
run:
- mkdir -p ./bin
- chmod -R 0777 ./bin
- make build-all

- name: Upload binaries
uses: xresloader/[email protected]
env:
Expand All @@ -93,17 +112,25 @@ jobs:
rolling-release-images:
env:
PROD_IMAGE_NAME: ghcr.io/${GITHUB_REPOSITORY}
VERSION: dev
# needs: [check, unit-test, integration-test-cli, integration-test-k8s, helm-chart-test]
needs: [check, unit-test, integration-test-cli, helm-chart-test]
name: Release images
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch

- name: Docker login
run: docker login ghcr.io -u ${{ github.actor }} -p "${{ secrets.GITHUB_TOKEN }}"

- name: Build and publish docker images
run: make build-publish-image-all
env:
VERSION: "branch-${{ steps.extract_branch.outputs.branch }}"

tagged-release-images:
# Only on tags.
Expand All @@ -116,11 +143,19 @@ jobs:
name: Tagged release images
runs-on: ubuntu-latest
steps:
- run: echo "VERSION=${GITHUB_REF#refs/*/}" >> ${GITHUB_ENV} # Sets VERSION env var.
- uses: actions/checkout@v4

- name: Extract tag
shell: bash
run: echo "tag=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/tags/}}" >> $GITHUB_OUTPUT
id: extract_tag

- name: Docker login
run: docker login ghcr.io -u ${{ github.actor }} -p "${{ secrets.GITHUB_TOKEN }}"

- name: Build and publish docker images
env:
VERSION: "${{ steps.extract_tag.outputs.tag }}"
run: make build-publish-image-all

# integration-test-k8s:
Expand Down

0 comments on commit dc40be5

Please sign in to comment.