Merge pull request #1 from shadyeip/ci/improve-workflows
ci: add PR validation and fix workflows for go-unifi dependency
This commit is contained in:
12
.github/workflows/acctest.yml
vendored
12
.github/workflows/acctest.yml
vendored
@@ -1,17 +1,5 @@
|
|||||||
name: Acceptance Tests
|
name: Acceptance Tests
|
||||||
on:
|
on:
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- "*"
|
|
||||||
# paths:
|
|
||||||
# - "internal/**"
|
|
||||||
# - "scripts/**"
|
|
||||||
# - "tools/**"
|
|
||||||
# - "main.go"
|
|
||||||
# - "docker-compose.yaml"
|
|
||||||
# - ".github/workflows/acctest.yml"
|
|
||||||
# - "Makefile"
|
|
||||||
# - "go.mod"
|
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- "main"
|
- "main"
|
||||||
|
|||||||
81
.github/workflows/ci.yaml
vendored
81
.github/workflows/ci.yaml
vendored
@@ -1,34 +1,79 @@
|
|||||||
---
|
---
|
||||||
|
name: ci
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request: {}
|
pull_request: {}
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- "main"
|
- main
|
||||||
tags:
|
|
||||||
- "v*"
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
# Runs on PRs: fast validation checks
|
||||||
runs-on: "ubuntu-latest"
|
validate:
|
||||||
|
if: github.event_name == 'pull_request'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- name: Checkout provider
|
||||||
- uses: actions/setup-go@v5
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
go-version-file: "go.mod"
|
path: terraform-provider-unifi
|
||||||
|
|
||||||
|
- name: Checkout go-unifi dependency
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
repository: shadyeip/go-unifi
|
||||||
|
path: go-unifi
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version-file: terraform-provider-unifi/go.mod
|
||||||
cache: true
|
cache: true
|
||||||
check-latest: true
|
check-latest: true
|
||||||
|
|
||||||
- run: "go build ./..."
|
- name: Check formatting
|
||||||
|
working-directory: terraform-provider-unifi
|
||||||
|
run: |
|
||||||
|
unformatted=$(gofmt -l .)
|
||||||
|
if [ -n "$unformatted" ]; then
|
||||||
|
echo "::error::Files not formatted with gofmt:"
|
||||||
|
echo "$unformatted"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
lint:
|
- name: Vet
|
||||||
runs-on: "ubuntu-latest"
|
working-directory: terraform-provider-unifi
|
||||||
steps:
|
run: go vet ./...
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/setup-go@v5
|
- name: Lint
|
||||||
|
uses: golangci/golangci-lint-action@v6.5.2
|
||||||
with:
|
with:
|
||||||
go-version-file: "go.mod"
|
working-directory: terraform-provider-unifi
|
||||||
|
skip-pkg-cache: true
|
||||||
|
|
||||||
|
# Runs on merge to main: full build
|
||||||
|
build:
|
||||||
|
if: github.event_name == 'push'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout provider
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
path: terraform-provider-unifi
|
||||||
|
|
||||||
|
- name: Checkout go-unifi dependency
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
repository: shadyeip/go-unifi
|
||||||
|
path: go-unifi
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version-file: terraform-provider-unifi/go.mod
|
||||||
|
cache: true
|
||||||
check-latest: true
|
check-latest: true
|
||||||
|
|
||||||
- uses: "golangci/golangci-lint-action@v6.5.2"
|
- name: Build
|
||||||
with:
|
working-directory: terraform-provider-unifi
|
||||||
skip-pkg-cache: true
|
run: go build ./...
|
||||||
|
|||||||
49
.github/workflows/release.yml
vendored
49
.github/workflows/release.yml
vendored
@@ -1,35 +1,74 @@
|
|||||||
name: goreleaser
|
name: release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- "v*"
|
- "v*"
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
tag:
|
||||||
|
description: "Version tag to release (e.g. v1.0.0)"
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
goreleaser:
|
release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
concurrency: release
|
concurrency: release
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout provider
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
path: terraform-provider-unifi
|
||||||
|
|
||||||
|
- name: Checkout go-unifi dependency
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
repository: shadyeip/go-unifi
|
||||||
|
path: go-unifi
|
||||||
|
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version-file: "go.mod"
|
go-version-file: "terraform-provider-unifi/go.mod"
|
||||||
check-latest: false
|
check-latest: false
|
||||||
|
|
||||||
|
- name: Determine version
|
||||||
|
id: version
|
||||||
|
working-directory: terraform-provider-unifi
|
||||||
|
run: |
|
||||||
|
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||||
|
echo "tag=${{ inputs.tag }}" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Create tag (workflow_dispatch only)
|
||||||
|
if: github.event_name == 'workflow_dispatch'
|
||||||
|
working-directory: terraform-provider-unifi
|
||||||
|
run: |
|
||||||
|
git tag "${{ steps.version.outputs.tag }}"
|
||||||
|
|
||||||
- name: Import GPG key
|
- name: Import GPG key
|
||||||
|
if: env.GPG_PRIVATE_KEY != ''
|
||||||
id: import_gpg
|
id: import_gpg
|
||||||
uses: crazy-max/ghaction-import-gpg@v6
|
uses: crazy-max/ghaction-import-gpg@v6
|
||||||
with:
|
with:
|
||||||
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
|
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
|
||||||
|
env:
|
||||||
|
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
|
||||||
|
|
||||||
- name: Run GoReleaser
|
- name: Run GoReleaser
|
||||||
uses: goreleaser/goreleaser-action@v6
|
uses: goreleaser/goreleaser-action@v6
|
||||||
with:
|
with:
|
||||||
version: latest
|
version: latest
|
||||||
args: release --parallelism 2 --clean
|
args: >-
|
||||||
|
release --parallelism 2 --clean
|
||||||
|
${{ steps.import_gpg.outputs.fingerprint == '' && '--skip=sign' || '' }}
|
||||||
|
workdir: terraform-provider-unifi
|
||||||
env:
|
env:
|
||||||
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
|
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|||||||
Reference in New Issue
Block a user