Skip to content

Commit

Permalink
chore(ci): Add build and ci
Browse files Browse the repository at this point in the history
  • Loading branch information
vmercierfr committed Sep 22, 2023
1 parent 56378e5 commit 8c2b461
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 1 deletion.
50 changes: 50 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: build
run-name: ${{ github.actor }} is building and publishing new release
on:
push:
# run only against tags
tags:
- "*"
permissions:
contents: write # allows the action to create a Github release
id-token: write # This is required for requesting the AWS JWT

jobs:
build-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-1 # ECR Public can only be logged into from the us-east-1 region
role-to-assume: arn:aws:iam::202662887508:role/ecr-prometheus-rds-exporter
role-session-name: githubActions

- name: Login to Amazon ECR
id: login-ecr-public
uses: aws-actions/amazon-ecr-login@v1
with:
registry-type: public
mask-password: 'true'

- run: git fetch --force --tags

- uses: actions/setup-go@v4
with:
go-version: stable

- uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Helm release
run: make helm-release
51 changes: 51 additions & 0 deletions .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: linter
on:
push:
branches:
- "*"

permissions:
contents: read

jobs:
golangci-lint:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.21'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Require: The version of golangci-lint to use.
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
version: v1.54

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
#
# Note: By default, the `.golangci.yml` file should be at the root of the repository.
# The location of the configuration file can be changed by using `--config=`
# args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

# Optional: if set to true, then all caching functionality will be completely disabled,
# takes precedence over all other caching options.
# skip-cache: true

# Optional: if set to true, then the action won't cache or restore ~/go/pkg.
# skip-pkg-cache: true

# Optional: if set to true, then the action won't cache or restore ~/.cache/go-build.
# skip-build-cache: true

# Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
# install-mode: "goinstall"
49 changes: 49 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: unittest
on:
push:
branches:
- "*"

permissions:
contents: read

jobs:
go:
name: go
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Install dependencies
run: |
go get .
- name: Build
run: make build
- name: Run Go tests
run: make test
helm:
name: helm
runs-on: ubuntu-latest
env:
HELM_UNITTEST_VERSION: v0.3.5
steps:
- uses: actions/checkout@v3
- name: Install helm-unittest
run: helm plugin install --version $HELM_UNITTEST_VERSION https://github.com/helm-unittest/helm-unittest.git
- name: Run Helm test
run: make helm-test
kubeconform:
name: kubeconform
runs-on: ubuntu-latest
env:
KUBECONFORM_VERSION: 0.6.2
steps:
- uses: actions/checkout@v3
- name: Install kubeconform
run: |
curl -sSLo /tmp/kubeconform.tar.gz "https://github.com/yannh/kubeconform/releases/download/v${KUBECONFORM_VERSION}/kubeconform-linux-amd64.tar.gz" \
&& tar -C /usr/local/bin/ -xzvf /tmp/kubeconform.tar.gz
- name: Run Kubeconform test
run: make kubeconform
1 change: 0 additions & 1 deletion configs/helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "prometheus-rds-exporter.selectorLabels" . | nindent 8 }}
{{- include "prometheus-rds-exporter.labels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
Expand Down

0 comments on commit 8c2b461

Please sign in to comment.