Skip to content

Commit

Permalink
Port to GitHub actions & publish to Terraform registry (#39)
Browse files Browse the repository at this point in the history
* Port to GitHub actions

* Fix

* Make docs terraform registry compatible
  • Loading branch information
gavinbunney authored Jul 15, 2021
1 parent 4adaea3 commit 0b0d03c
Show file tree
Hide file tree
Showing 55 changed files with 265 additions and 7,652 deletions.
92 changes: 92 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: "Build"

on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
build:
runs-on: ubuntu-latest
env:
GO111MODULE: on
steps:
- uses: actions/checkout@v2
- name: Set up GO 1.16.x
uses: actions/setup-go@v1
with:
go-version: '1.16'
- run: echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Setup Environment
run: make ci-build-setup
- name: Build
run: make build
test:
runs-on: ubuntu-latest
env:
GO111MODULE: on
steps:
- uses: actions/checkout@v2
- name: Set up GO 1.16.x
uses: actions/setup-go@v1
with:
go-version: '1.16'
- run: echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Setup Environment
run: make ci-build-setup
- name: Run tests
run: make test
testacc:
runs-on: ubuntu-latest
env:
GO111MODULE: on
steps:
- uses: actions/checkout@v2
- name: Set up GO 1.16.x
uses: actions/setup-go@v1
with:
go-version: '1.16'
- run: echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Setup Environment
run: make ci-build-setup
- name: Start bitbucket server
run: make bitbucket-start
- name: Run acceptance tests
run: BITBUCKET_SERVER=http://localhost:7990 BITBUCKET_USERNAME=admin BITBUCKET_PASSWORD=admin make testacc
- name: Stop bitbucket server
run: make bitbucket-stop
fmtcheck:
runs-on: ubuntu-latest
env:
GO111MODULE: on
steps:
- uses: actions/checkout@v2
- name: Set up GO 1.16.x
uses: actions/setup-go@v1
with:
go-version: '1.16'
- run: echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Setup Environment
run: make ci-build-setup
- name: Format check
run: make fmtcheck
vet:
runs-on: ubuntu-latest
env:
GO111MODULE: on
steps:
- uses: actions/checkout@v2
- name: Set up GO 1.16.x
uses: actions/setup-go@v1
with:
go-version: '1.16'
- run: echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Setup Environment
run: make ci-build-setup
- name: Run vet
run: make vet
40 changes: 40 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Release

on:
push:
tags:
- "v*"

permissions:
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v3
with:
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
- name: Upload assets
uses: actions/upload-artifact@v2
with:
path: dist/*
1 change: 0 additions & 1 deletion .go-version

This file was deleted.

46 changes: 46 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
before:
hooks:
- go mod tidy
builds:
- env:
# goreleaser does not work with CGO, it could also complicate
# usage by users in CI/CD systems like Terraform Cloud where
# they are unable to install libraries.
- CGO_ENABLED=0
mod_timestamp: '{{ .CommitTimestamp }}'
flags:
- -trimpath
ldflags:
- '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}'
goos:
- windows
- linux
- darwin
goarch:
- amd64
- '386'
- arm
- arm64
ignore:
- goos: darwin
goarch: '386'
binary: '{{ .ProjectName }}_v{{ .Version }}'
archives:
- id: zip
format: zip
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
checksum:
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
algorithm: sha256
signs:
- artifacts: checksum
args:
- "--batch"
- "--local-user"
- "{{ .Env.GPG_FINGERPRINT }}" # set this environment variable for your signing key
- "--output"
- "${signature}"
- "--detach-sign"
- "${artifact}"
release:
draft: false
40 changes: 0 additions & 40 deletions .travis.yml

This file was deleted.

30 changes: 18 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,17 @@ testacc: fmtcheck
ulimit -n 1024; TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m -count=1

testacc-bitbucket: fmtcheck
@sh scripts/start-docker-compose.sh
@bash scripts/start-docker-compose.sh
#The ulimit command is required to allow the tests to open more than the default 256 files as set on MacOS. The tests will fail without this. It must be done as one
#command otherwise the setting is lost
ulimit -n 1024; TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m -count=1
@sh scripts/stop-docker-compose.sh
@bash scripts/stop-docker-compose.sh

bitbucket-start:
@bash scripts/start-docker-compose.sh

bitbucket-stop:
@bash scripts/stop-docker-compose.sh

vet:
@echo "go vet ."
Expand All @@ -44,13 +50,13 @@ fmt:
gofmt -w $(GOFMT_FILES)

fmtcheck:
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"
@bash -c "'$(CURDIR)/scripts/gofmtcheck.sh'"

errcheck:
@sh -c "'$(CURDIR)/scripts/errcheck.sh'"
@bash -c "'$(CURDIR)/scripts/errcheck.sh'"

build-binaries:
@sh -c "'$(CURDIR)/scripts/build.sh'"
@bash -c "'$(CURDIR)/scripts/build.sh'"

test-compile:
@if [ "$(TEST)" = "./..." ]; then \
Expand All @@ -60,11 +66,11 @@ test-compile:
fi
go test -c $(TEST) $(TESTARGS)

website-serve:
@cd docusaurus/website && npm start

website-publish:
@cd docusaurus/website && npm run build
@cd docusaurus/website && CURRENT_BRANCH=master USE_SSH=true npm run publish-gh-pages
ci-build-setup:
sudo rm /usr/local/bin/docker-compose
curl -L https://github.com/docker/compose/releases/download/1.25.4/docker-compose-`uname -s`-`uname -m` > docker-compose
chmod +x docker-compose
sudo mv docker-compose /usr/local/bin
bash scripts/gogetcookie.sh

.PHONY: build test testacc vet fmt fmtcheck errcheck test-compile build-binaries website-serve website-publish
.PHONY: build test testacc vet fmt fmtcheck errcheck test-compile build-binaries ci-build-setup bitbucket-start bitbucket-stop
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
id: data_bitbucketserver_application_properties
title: bitbucketserver_application_properties
---
# Data Source: bitbucketserver_application_properties

This data source allows you to retrieve version information and other application properties of Bitbucket Server.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
id: data_bitbucketserver_cluster
title: bitbucketserver_cluster
---
# Data Source: bitbucketserver_cluster

Gets information about the nodes that currently make up the Bitbucket cluster.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
id: data_bitbucketserver_global_permissions_groups
title: bitbucketserver_global_permissions_groups
---
# Data Source: bitbucketserver_global_permissions_groups

Retrieve a list of groups that have been granted at least one global permission.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
id: data_bitbucketserver_group_users
title: bitbucketserver_group_users
---
# Data Source: bitbucketserver_group_users

Retrieve a list of users for a specific group.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
id: data_bitbucketserver_groups
title: bitbucketserver_groups
---
# Data Source: bitbucketserver_groups

This data source allows you to retrieve a list of groups, optionally matching the supplied `filter`.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
id: data_bitbucketserver_plugin
title: bitbucketserver_plugin
---
# Data Source: bitbucketserver_plugin

This data source allows you to retrieve installed plugin information and license details.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
id: data_bitbucketserver_project_hooks
title: bitbucketserver_project_hooks
---
# Data Source: bitbucketserver_project_hooks

Retrieve a list of project hooks and their status' for the specified project.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
id: data_bitbucketserver_project_permissions_groups
title: bitbucketserver_project_permissions_groups
---
# Data Source: bitbucketserver_project_permissions_groups

Retrieve a list of groups that have been granted at least one project level permission to the specified project.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
id: data_bitbucketserver_project_permissions_users
title: bitbucketserver_project_permissions_users
---
# Data Source: bitbucketserver_project_permissions_users

Retrieve a list of users that have been granted at least one permission for the specified project.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
id: data_bitbucketserver_repository_hooks
title: bitbucketserver_repository_hooks
---
# Data Source: bitbucketserver_repository_hooks

Retrieve a list of repository hooks and their status' for the specified repo.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
id: data_bitbucketserver_repository_permissions_groups
title: bitbucketserver_repository_permissions_groups
---
# Data Source: bitbucketserver_repository_permissions_groups

Retrieve a list of groups that have been granted at least one repository level permission to the specified repo.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
id: data_bitbucketserver_repository_permissions_users
title: bitbucketserver_repository_permissions_users
---
# Data Source: bitbucketserver_repository_permissions_users

Retrieve a list of users that have been granted at least one permission for the specified repository.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
id: data_bitbucketserver_user
title: bitbucketserver_user
---
# Data Source: bitbucketserver_user

This data source allows you to retrieve Bitbucket user details.

Expand Down
Loading

0 comments on commit 0b0d03c

Please sign in to comment.