Skip to content

Commit

Permalink
Setup ginkgo and testcontainers (#4)
Browse files Browse the repository at this point in the history
* Add test step

* The test suite

* More docker stuff

* Install more tools

* Try updating the action

* Unshallow clone for tags

* Well I gotta make the provisioner duh

* God dammit

* Am I dumb?
  • Loading branch information
UnstoppableMango authored Jul 27, 2024
1 parent 08d422b commit 7c956f4
Show file tree
Hide file tree
Showing 11 changed files with 350 additions and 34 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!bin/
39 changes: 39 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:recommended"
],
"automerge": true,
"customManagers": [
{
"customType": "regex",
"depNameTemplate": "dprint/dprint",
"datasourceTemplate": "github-releases",
"fileMatch": [
".*\\/.*\\.ya?ml"
],
"matchStrings": [
"dprint-version: (?<currentValue>.*)"
]
},
{
"customType": "regex",
"depNameTemplate": "pulumi/pulumi",
"datasourceTemplate": "github-releases",
"fileMatch": [
"\\.versions\\/pulumi"
],
"matchStrings": [
"(?<currentValue>\\d+\\.\\d+\\.\\d+)"
]
}
],
"packageRules": [
{
"groupName": "pulumi",
"matchDepNames": [
"pulumi/pulumi$"
]
}
]
}
53 changes: 53 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,70 @@ jobs:
- name: Make
run: make provisioner

- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: provisioner
path: bin/provisioner

provider:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Unshallow clone for tags
run: git fetch --prune --unshallow --tags

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: provider/go.mod
cache-dependency-path: provider/go.sum

- name: Install pulumictl
uses: jaxxstorm/[email protected]
with:
repo: pulumi/pulumictl

- name: Install Pulumi
uses: pulumi/actions@v5
with:
pulumi-version-file: .versions/pulumi

- name: Make
run: make provider

test:
runs-on: ubuntu-latest
needs: [provisioner, provider]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: provider/go.mod
cache-dependency-path: provider/go.sum

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Download provisioner
uses: actions/download-artifact@v4
with:
name: provisioner
path: bin

- name: Build and push
uses: docker/build-push-action@v6
with:
push: false
cache-from: type=gha
cache-to: type=gha
context: .
file: tests/Dockerfile

- name: Test
run: make test_provider
16 changes: 10 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
tags:
- v*.*.*
- '!v*.*.*-**'

env:
PROVIDER: baremetal
GITHUB_TOKEN: ${{ github.token }}
Expand All @@ -15,6 +16,7 @@ env:
NUGET_FEED_URL: https://api.nuget.org/v3/index.json
PYPI_PASSWORD: ${{ secrets.PYPI_TOKEN }}
PYPI_USERNAME: __token__

jobs:
publish_binary:
name: publish
Expand All @@ -26,18 +28,19 @@ jobs:
- 1.17.x
steps:
- name: Checkout Repo
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Unshallow clone for tags
run: git fetch --prune --unshallow --tags

- name: Install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.goversion }}
cache-dependency-path: provider/go.sum

- name: Install pulumictl
uses: jaxxstorm/action-install-gh-release@v1.5.0
uses: jaxxstorm/action-install-gh-release@v1.12.0
with:
repo: pulumi/pulumictl

Expand Down Expand Up @@ -69,18 +72,19 @@ jobs:
- '3.9'
steps:
- name: Checkout Repo
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Unshallow clone for tags
run: git fetch --prune --unshallow --tags

- name: Install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.goversion }}
cache-dependency-path: provider/go.sum

- name: Install pulumictl
uses: jaxxstorm/action-install-gh-release@v1.5.0
uses: jaxxstorm/action-install-gh-release@v1.12.0
with:
repo: pulumi/pulumictl

Expand Down
1 change: 1 addition & 0 deletions .versions/pulumi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.127.0
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ provider::
provider_debug::
(cd provider && go build -o $(WORKING_DIR)/bin/${PROVIDER} -gcflags="all=-N -l" -ldflags "-X ${PROJECT}/${VERSION_PATH}=${VERSION}" $(PROJECT)/${PROVIDER_PATH}/cmd/$(PROVIDER))

test_provider::
cd tests && go test -short -v -count=1 -cover -timeout 2h -parallel ${TESTPARALLELISM} ./...
test_provider:: provisioner
cd tests && go test -short -v -count=1 -cover -timeout 2h ./...

provisioner:: bin/provisioner

Expand Down Expand Up @@ -149,4 +149,4 @@ install_nodejs_sdk::

# ------- Real Targets -------
bin/provisioner::
cd provider && go build -o $@ $(PROJECT)/${PROVIDER_PATH}/cmd/provisioner
cd provider && go build -o ${WORKING_DIR}/$@ $(PROJECT)/${PROVIDER_PATH}/cmd/provisioner
4 changes: 4 additions & 0 deletions tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM ubuntu:noble-20240605

WORKDIR /app
COPY bin/provisioner .
45 changes: 44 additions & 1 deletion tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,27 @@ replace github.com/unmango/pulumi-baremetal/provider => ../provider

require (
github.com/blang/semver v3.5.1+incompatible
github.com/onsi/ginkgo/v2 v2.19.1
github.com/onsi/gomega v1.34.0
github.com/pulumi/pulumi-go-provider v0.21.0
github.com/pulumi/pulumi/sdk/v3 v3.127.0
github.com/stretchr/testify v1.9.0
github.com/testcontainers/testcontainers-go v0.32.0
github.com/unmango/pulumi-baremetal/provider v0.0.0-20240727032834-1cd9f8273673
)

require (
dario.cat/mergo v1.0.0 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/BurntSushi/toml v1.4.0 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/Microsoft/hcsshim v0.11.5 // indirect
github.com/ProtonMail/go-crypto v1.0.0 // indirect
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect
github.com/agext/levenshtein v1.2.3 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/charmbracelet/bubbles v0.18.0 // indirect
github.com/charmbracelet/bubbletea v0.26.6 // indirect
github.com/charmbracelet/lipgloss v0.12.1 // indirect
Expand All @@ -31,18 +36,33 @@ require (
github.com/charmbracelet/x/windows v0.1.2 // indirect
github.com/cheggaaa/pb v1.0.29 // indirect
github.com/cloudflare/circl v1.3.9 // indirect
github.com/containerd/containerd v1.7.18 // indirect
github.com/containerd/errdefs v0.1.0 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/cpuguy83/dockercfg v0.3.1 // indirect
github.com/cyphar/filepath-securejoin v0.3.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/djherbis/times v1.6.0 // indirect
github.com/docker/docker v27.0.3+incompatible // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/edsrzf/mmap-go v1.1.0 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.5.0 // indirect
github.com/go-git/go-git/v5 v5.12.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/glog v1.2.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
Expand All @@ -51,16 +71,27 @@ require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/klauspost/compress v1.17.4 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/mitchellh/go-ps v1.0.0 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/patternmatcher v0.6.0 // indirect
github.com/moby/sys/sequential v0.5.0 // indirect
github.com/moby/sys/user v0.1.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/termenv v0.15.2 // indirect
github.com/natefinch/atomic v1.0.1 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/opentracing/basictracer-go v1.1.0 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pgavlin/fx v0.1.6 // indirect
Expand All @@ -69,6 +100,7 @@ require (
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/term v1.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/pulumi/appdash v0.0.0-20231130102222-75f619a67231 // indirect
github.com/pulumi/esc v0.9.1 // indirect
github.com/pulumi/pulumi/pkg/v3 v3.127.0 // indirect
Expand All @@ -79,16 +111,27 @@ require (
github.com/segmentio/asm v1.2.0 // indirect
github.com/segmentio/encoding v0.4.0 // indirect
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
github.com/shirou/gopsutil/v3 v3.23.12 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/skeema/knownhosts v1.3.0 // indirect
github.com/spf13/cobra v1.8.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.9.0 // indirect
github.com/texttheater/golang-levenshtein v1.0.1 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/tweekmonster/luser v0.0.0-20161003172636-3fa38070dbd7 // indirect
github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
github.com/zclconf/go-cty v1.15.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
Expand Down
Loading

0 comments on commit 7c956f4

Please sign in to comment.