Skip to content

🛠️ Build - main #63

🛠️ Build - main

🛠️ Build - main #63

Workflow file for this run

name: build
run-name: '🛠️ Build - ${{ github.ref_name }}'
on:
push:
branches:
- main
pull_request_target:
branches:
- main
types:
- opened
- reopened
- synchronize
permissions:
contents: read
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
build:
name: Go Build
runs-on: ubuntu-latest
steps:
- name: Checkout 💻
uses: actions/[email protected]
- name: Setup Go environment ⚙️
uses: actions/[email protected]
with:
go-version-file: 'go.mod'
cache: true
- name: Go Pkg Install 📦
run: go mod download
- name: Go Build 🛠️
run: go build -v ./...
test-unit:
name: Go Unit Test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
go-version:
- '1.21'
- '1.22'
needs:
- build
steps:
- name: Checkout 💻
uses: actions/[email protected]
- name: Setup Go environment ⚙️
uses: actions/[email protected]
with:
go-version: ${{ matrix.go-version }}
- name: Go Pkg Install 📦
run: go mod download
- name: Go Unit Test 🧪
run: go test ./... -v -coverprofile=unit-test.lcov -json > unit-test.log
- name: Upload Unit Test Artifacts ⏫
uses: actions/[email protected]
if: ${{ success() }}
with:
name: unit-test-reports-${{ github.sha }}
path: |
unit-test.lcov
unit-test.log
retention-days: 7
overwrite: true
compression-level: 1 # best speed
test-acc:
name: Go Acceptance Test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
tf-version:
- '1.6.*'
- '1.7.*'
- '1.8.*'
steps:
- name: Checkout 💻
uses: actions/[email protected]
- name: Setup Go environment ⚙️
uses: actions/[email protected]
with:
go-version: '1.21'
- name: Terraform Setup 🏗️
uses: hashicorp/[email protected]
with:
terraform_version: ${{ matrix.tf-version }}
terraform_wrapper: false
- name: Go Acceptance Test 🧪
run: go test ./internal/provider -v -coverprofile=acc-test.lcov -json > acc-test.log
env:
TF_ACC: '1'
- name: Upload coverage reports to Codecov ☂️
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
files: unit-test.lcov,acc-test.lcov
- name: Upload Acceptance Test Artifacts ⏫
uses: actions/[email protected]
if: ${{ success() }}
with:
name: acc-test-reports-${{ github.sha }}
path: |
acc-test.lcov
acc-test.log
retention-days: 7
overwrite: true
compression-level: 1 # best speed
generate:
name: Go Generate
runs-on: ubuntu-latest
needs:
- build
- test-unit
- test-acc
steps:
- name: Checkout 💻
uses: actions/[email protected]
- name: Setup Go environment ⚙️
uses: actions/[email protected]
with:
go-version-file: 'go.mod'
cache: true
- name: Go Generate 📜
run: go generate ./...
sonarcloud:
name: SonarCloud Scan
runs-on: ubuntu-latest
needs:
- build
- test-unit
- test-acc
steps:
- name: Checkout 💻
uses: actions/[email protected]
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
- name: Download Unit Test Artifact ⏬
uses: actions/[email protected]
with:
name: unit-test-reports-${{ github.sha }}
- name: Download Acceptance Test Artifact ⏬
uses: actions/[email protected]
with:
name: acc-test-reports-${{ github.sha }}
- name: SonarCloud Scan 🎯
uses: sonarsource/[email protected] # See the latest version at https://github.com/marketplace/actions/sonarcloud-scan
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}