Skip to content

Commit

Permalink
feat(TR6): rebase, dependency update and test run
Browse files Browse the repository at this point in the history
  • Loading branch information
tgraupne committed Oct 29, 2024
1 parent 4b4d6c8 commit c563f11
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 24 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ jobs:

- name: Check out repo
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Setup Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version-file: 'go.mod'
cache: true

- name: Install Go dependencies
run: go mod tidy

- name: Install build dependencies
run: sudo apt update && sudo apt install musl-tools -y

Expand All @@ -34,12 +35,9 @@ jobs:
terraform_version: '1.9.2'
terraform_wrapper: false

- name: Install Go dependencies
run: go mod tidy

- name: Generate documentation
run: |
go generate ./...
make create-docs-linux
- name: Git diff
run: |
Expand Down
32 changes: 16 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ jobs:
dependencies: musl-tools
- os: ubuntu-22.04
arch: arm64
runner: ubuntu-22.04 # This should be the arm runner to enable native compilation
runner: Terraform-provider-bitwarden-sm-linux
build_target: build-linux-arm64
verify-target: verify-binary-linux
dependencies: gcc-aarch64-linux-gnu musl musl-dev musl-tools #This is not enough to enable cross-compilation
dependencies: musl-tools
- os: darwin
arch: amd64
runner: macos-14
Expand Down Expand Up @@ -66,13 +66,6 @@ jobs:
go-version-file: 'go.mod'
cache: true

- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6.1.0
id: import_gpg
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}

- name: Install dependencies (Linux only)
if: matrix.os == 'ubuntu-22.04'
run: sudo apt update && sudo apt install -y ${{ matrix.dependencies }}
Expand All @@ -94,11 +87,11 @@ jobs:
id: prepare-release
run: |
MODULE_NAME=$(grep "^module" go.mod | awk -F'/' '{print $NF}')
VERSION=$(echo ${{ github.ref_name }} | sed 's/^v//')
ARCHIVE="${MODULE_NAME}_${VERSION}_${{ matrix.os }}_${{ matrix.arch }}.zip"
BINARY_VERSION=$(echo ${{ github.ref_name }})
ARCHIVE="${MODULE_NAME}_${BINARY_VERSION}_${{ matrix.os }}_${{ matrix.arch }}.zip"
# Conditionally set the binary name with or without .exe extension
BINARY="${MODULE_NAME}_v${VERSION}"
BINARY="${MODULE_NAME}_${BINARY_VERSION}"
if [ "${{ matrix.os }}" = "windows" ]; then
BINARY="${BINARY}.exe"
fi
Expand All @@ -107,16 +100,16 @@ jobs:
zip ${ARCHIVE} ${BINARY}
echo "module_name=${MODULE_NAME}" >> "$GITHUB_OUTPUT"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
echo "version=${BINARY_VERSION}" >> "$GITHUB_OUTPUT"
echo "module_name=${MODULE_NAME}" >> "$GITHUB_ENV"
echo "version=${VERSION}" >> "$GITHUB_ENV"
echo "binary_version=${BINARY_VERSION}" >> "$GITHUB_ENV"
echo "archive=${ARCHIVE}" >> "$GITHUB_ENV"
- name: Upload artifacts
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
with:
name: ${{ env.module_name }}_${{ env.version }}_${{ matrix.os }}_${{ matrix.arch }}
name: ${{ env.module_name }}_${{ env.binary_version }}_${{ matrix.os }}_${{ matrix.arch }}
retention-days: 5
path: |
${{ env.archive }}
Expand All @@ -130,6 +123,13 @@ jobs:
- name: Check out repo
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6.1.0
id: import_gpg
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}

- name: Download ZIP files
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
Expand All @@ -155,4 +155,4 @@ jobs:
release/*.zip
terraform-registry-manifest.json
release/${{ needs.build-artifact.outputs.module_name }}_${{ needs.build-artifact.outputs.version }}_SHA256SUMS
release/${{ needs.build-artifact.outputs.module_name }}_${{ needs.build-artifact.outputs.version }}_SHA256SUMS.sig
# release/${{ needs.build-artifact.outputs.module_name }}_${{ needs.build-artifact.outputs.version }}_SHA256SUMS.sig
7 changes: 5 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ linters:
enable:
- durationcheck
- errcheck
- exportloopref
- forcetypeassert
- godot
- gofmt
Expand All @@ -23,4 +22,8 @@ linters:
- unconvert
- unparam
- unused
- vet
- govet
- copyloopvar

run:
timeout: 3m
17 changes: 17 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ set-env-windows: set-env
go env -w CC=/usr/bin/x86_64-w64-mingw32-gcc
go env -w CGO_LDFLAGS=$(PARAM_CGO_LDFLAGS)

# Generate documentation on linux
.PHONY: create-docs-linux
create-docs-linux: set-env-linux
terraform fmt -recursive ./examples/
go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs generate

# Build a static linux binary
.PHONY: build-linux
build-linux: set-env-linux
Expand Down Expand Up @@ -127,3 +133,14 @@ testacc_tofu:
TF_ACC_PROVIDER_NAMESPACE="hashicorp" \
TF_ACC_PROVIDER_HOST="registry.opentofu.org" \
go test $(TEST) -v $(TESTARGS) -timeout 10m

# Reset local go env
.PHONY: reset-go-env
reset-go-env:
go env -u GOROOT
go env -u GOPATH
go env -u GOARCH
go env -u GOOS
go env -u CGO_ENABLED
go env -u GO111MODULE
go env -u CGO_LDFLAGS
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ require (
go.abhg.dev/goldmark/frontmatter v0.2.0 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df // indirect
go.abhg.dev/goldmark/frontmatter v0.2.0 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.26.0 // indirect
Expand Down

0 comments on commit c563f11

Please sign in to comment.