diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..6682530 --- /dev/null +++ b/.github/workflows/build.yaml @@ -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 diff --git a/.github/workflows/golangci-lint.yaml b/.github/workflows/golangci-lint.yaml new file mode 100644 index 0000000..36291d5 --- /dev/null +++ b/.github/workflows/golangci-lint.yaml @@ -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" diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..5d2c42d --- /dev/null +++ b/.github/workflows/test.yaml @@ -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 \ No newline at end of file diff --git a/configs/helm/templates/deployment.yaml b/configs/helm/templates/deployment.yaml index 9336e09..ef775be 100644 --- a/configs/helm/templates/deployment.yaml +++ b/configs/helm/templates/deployment.yaml @@ -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 }}