Initial ports service #12
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI/CD | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.22' | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v6 | |
with: | |
version: v1.60 | |
# lint the dockerfile too | |
- uses: hadolint/[email protected] | |
with: | |
dockerfile: Dockerfile | |
# lint and validate the helm chart | |
- name: Cache Helm & Kubeconform | |
uses: actions/cache@v3 | |
with: | |
path: | | |
./helm | |
./kubeconform | |
key: ${{ runner.os }}-helm-v3.12.0-kubeconform-v0.6.7 | |
restore-keys: | | |
${{ runner.os }}-helm- | |
${{ runner.os }}-kubeconform- | |
- name: Install Helm & Kubeconform | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: | | |
# i would build a generic docker image with tools like this in, and probably even a shared action in a | |
# .github private repo that i could use in all my projects | |
curl -LO https://get.helm.sh/helm-v3.12.0-linux-amd64.tar.gz | |
tar -xzf helm-v3.12.0-linux-amd64.tar.gz | |
mv linux-amd64/helm ./helm | |
curl -LO https://github.com/yannh/kubeconform/releases/download/v0.6.7/kubeconform-linux-amd64.tar.gz | |
tar -xzf kubeconform-linux-amd64.tar.gz | |
rm helm-v3.12.0-linux-amd64.tar.gz | |
rm kubeconform-linux-amd64.tar.gz | |
- name: Move binaries to /usr/local/bin | |
run: | | |
sudo mv ./helm /usr/local/bin/ | |
sudo mv ./kubeconform /usr/local/bin/ | |
- name: Validate Helm Charts with Kubeconform | |
run: | | |
helm template helm/port-service | kubeconform -exit-on-error -strict -summary -schema-location https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/{{.ResourceKind}}/{{.ResourceAPIVersion}} -skip CustomResourceDefinition,MutatingWebhookConfiguration,ValidatingWebhookConfiguration | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.22' | |
- name: Run tests | |
run: | | |
go test -v ./... | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.22' | |
- name: Build the project | |
run: | | |
go build -v ./... |