Skip to content

Merge pull request #60 from SuperBuker/dependabot/go_modules/golang.o… #374

Merge pull request #60 from SuperBuker/dependabot/go_modules/golang.o…

Merge pull request #60 from SuperBuker/dependabot/go_modules/golang.o… #374

Workflow file for this run

name: Golang
on:
pull_request:
paths-ignore:
- "README.md"
push:
paths-ignore:
- "README.md"
workflow_dispatch:
inputs:
debug_mode:
description: "Silent failure, output tests results"
type: boolean
required: false
default: false
permissions:
contents: read
concurrency:
group: "default" # Static value, to prevent concurrent runs
cancel-in-progress: false # Cancel previous runs if a new one is started
jobs:
testing:
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
max-parallel: 1
matrix:
go-version: ["1.21.x"] # To extend
terraform-version: ["1.0.x", "1.1.x", "1.2.x", "1.3.x", "1.4.x"] # To extend
steps:
- uses: actions/checkout@v4.1.1
- name: Setup Go ${{ matrix.go-version }}
uses: actions/setup-go@v5.0.0
with:
go-version: ${{ matrix.go-version }}
cache: true
- name: Display Go version
run: go version
- uses: hashicorp/setup-terraform@v3.0.0
with:
terraform_version: ${{ matrix.terraform-version }}
terraform_wrapper: false
- name: Display Terraform version
run: terraform version
- name: Terraform provider cache
uses: actions/cache@v3.3.2
with:
key: terraform-provider-dns-he-net
path: ~/.config/terraform-provider-dns-he-net/
- name: Install dependencies
run: go mod download
- name: Run linter
uses: golangci/golangci-lint-action@v3.7.0
with:
args: --timeout=10m
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.52.0
- name: Run go vet
run: go vet ./...
- name: Unit tests, with terraform coverage and retries
env:
DNSHENET_USER: ${{ secrets.DNSHENET_USER }}
DNSHENET_PASSWD: ${{ secrets.DNSHENET_PASSWD }}
DNSHENET_OTP: ${{ secrets.DNSHENET_OTP }}
DNSHENET_ACCOUNT_ID: ${{ secrets.DNSHENET_ACCOUNT_ID }}
DNSHENET_TEST_CONFIG_PATH: ${{ vars.DNSHENET_TEST_CONFIG_PATH }}
TEST_CONFIG: ${{ secrets.TEST_CONFIG }}
TF_ACC: "1"
# Use the retry action
uses: nick-fields/retry@v2.9.0
with:
command: |
DNSHENET_TEST_CONFIG_PATH="${PWD}/${DNSHENET_TEST_CONFIG_PATH}" # Set the absolute path
DEBUG_MODE=${{ github.event.inputs.debug_mode }}
DEBUG_MODE=${DEBUG_MODE:-"false"} # Use user input or fall back to "false"
"${DEBUG_MODE}" && echo "Debug mode enabled"
echo "${TEST_CONFIG}" > "${DNSHENET_TEST_CONFIG_PATH}"
go test -v ./... -covermode count -coverprofile coverage.out -json > TestResults-${{ matrix.go-version }}-${{ matrix.terraform-version }}.json || "${DEBUG_MODE}"
go tool cover -func coverage.out
# continue_on_error: false
max_attempts: 3
on_retry_command: echo "Retrying..." # TODO: Add script to clean up testing environment
retry_on: error
shell: bash
timeout_minutes: 10
- name: Upload Go test results
uses: actions/upload-artifact@v3.1.3
with:
name: Go-results-${{ matrix.go-version }}-${{ matrix.terraform-version }}
path: TestResults-${{ matrix.go-version }}-${{ matrix.terraform-version }}.json
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3.1.4