Skip to content

Commit

Permalink
feat: CICD refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
alekc committed Dec 10, 2022
1 parent 035b63f commit 4788b7f
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 246 deletions.
92 changes: 0 additions & 92 deletions .github/workflows/build.yml

This file was deleted.

59 changes: 59 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: "tests"
on:
push:
branches:
- master
pull_request:
branches:
- master

env:
KUBECONFIG: ${{ github.workspace }}/.kube/config

jobs:
get_version_matrix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- id: get_version_matrix
shell: bash
run: scripts/get-version-matrix.sh
outputs:
version_matrix: ${{ steps.get_version_matrix.outputs.matrix }}
unit_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: go.mod
- name: Unit tests
env:
GOPATH: /home/runner/go
run: |
make test
make vet
acc_test:
needs: get_version_matrix
runs-on: ubuntu-latest
strategy:
matrix:
terraform_version: ${{ fromJson(needs.get_version_matrix.outputs.version_matrix) }}
steps:
- uses: actions/checkout@master
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: go.mod
- uses: helm/kind-action@v1.4.0
id: kind
with:
wait: 2m
- name: Acceptance Tests
env:
KUBE_CONFIG_PATH: ${{ env.KUBECONFIG }}
TF_ACC_TERRAFORM_VERSION: ${{ matrix.terraform_version }}
TESTARGS: "-parallel 1"
run: |
make testacc
19 changes: 1 addition & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ PKG_NAME=kubernetes
export GO111MODULE=on

export TESTARGS=-race -coverprofile=coverage.txt -covermode=atomic
export KUBECONFIG=$(CURRENT_DIR)/scripts/kubeconfig.yaml

default: build

Expand All @@ -23,12 +22,6 @@ test:
testacc:
TF_ACC=1 go test ./kubernetes -v $(TESTARGS) -timeout 120m -count=1

k3s-start:
@bash scripts/start-k3s.sh

k3s-stop:
@bash scripts/stop-k3s.sh

publish:
goreleaser release --rm-dist

Expand All @@ -50,14 +43,4 @@ fmtcheck:
errcheck:
@sh -c "'$(CURDIR)/scripts/errcheck.sh'"

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
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.20.7/bin/linux/amd64/kubectl
chmod +x kubectl
sudo mv kubectl /usr/local/bin/
bash scripts/gogetcookie.sh

.PHONY: build dist test testacc k3s-start k3s-stop publish vet fmt fmtcheck errcheck ci-build-setup
.PHONY: build dist test testacc publish vet fmt fmtcheck errcheck
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Kubernetes "kubectl" Provider

![Build Status](https://github.com/alekc/terraform-provider-kubectl/actions/workflows/build.yml/badge.svg) [![user guide](https://img.shields.io/badge/-user%20guide-blue)](https://registry.terraform.io/providers/alekc/kubectl)
![Build Status](https://github.com/alekc/terraform-provider-kubectl/actions/workflows/tests.yml/badge.svg) [![user guide](https://img.shields.io/badge/-user%20guide-blue)](https://registry.terraform.io/providers/alekc/kubectl)

This provider is the best way of managing Kubernetes resources in Terraform, by allowing you to use the thing
Kubernetes loves best - yaml!
Expand Down
31 changes: 0 additions & 31 deletions scripts/build.sh

This file was deleted.

28 changes: 0 additions & 28 deletions scripts/docker-compose.yaml

This file was deleted.

9 changes: 9 additions & 0 deletions scripts/get-version-matrix.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

function get_latest_version() {
curl -s https://api.github.com/repos/hashicorp/terraform/git/refs/tags | \
jq ".[] | .ref | split(\"/\") | .[2] | select(. | startswith(\"$1\"))" | \
sort -V -r | head -1
}

echo "::set-output name=matrix::[$(get_latest_version v0.12), $(get_latest_version v0.13), $(get_latest_version v0.14), $(get_latest_version v0.15), $(get_latest_version v1.0), $(get_latest_version v1.1), $(get_latest_version v1.2), $(get_latest_version v1.3)]"
4 changes: 0 additions & 4 deletions scripts/registries.yaml

This file was deleted.

61 changes: 0 additions & 61 deletions scripts/start-k3s.sh

This file was deleted.

11 changes: 0 additions & 11 deletions scripts/stop-k3s.sh

This file was deleted.

0 comments on commit 4788b7f

Please sign in to comment.