Skip to content

Merge pull request #275 from hypnoglow/dependabot/go_modules/github.c… #229

Merge pull request #275 from hypnoglow/dependabot/go_modules/github.c…

Merge pull request #275 from hypnoglow/dependabot/go_modules/github.c… #229

Workflow file for this run

name: main
on:
push:
branches:
- master
pull_request:
branches:
- '*'
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
- name: Setup Go
uses: actions/setup-go@268d8c0ca0432bb2cf416faae41297df9d262d7f # v3.3.0
with:
cache: true
go-version-file: 'go.mod'
- name: Download dependencies
run: |
go mod download -x
- name: Run tests
run: |
go test -v -race -coverprofile=coverage.txt -covermode=atomic $(go list ./... | grep -v e2e)
- name: Codecov
uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1
- name: Run linters
uses: golangci/golangci-lint-action@537aa1903e5d359d0b27dbc19ddd22c5087f3fbc # v3.2.0
with:
version: v1.48
args: --verbose
# See: https://github.com/golangci/golangci-lint-action/issues/244
skip-pkg-cache: true
skip-build-cache: true
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@94e0aab03ca135d11a35e5bfc14e6746dc56e7e9 # v1.1.0
with:
severity: warning
- name: Build
run: |
go build -v -o ./bin/helm-s3 ./cmd/helm-s3
test-e2e:
name: Run end-to-end tests
needs:
- build
runs-on: ubuntu-latest
strategy:
matrix:
helm:
- 2.17.0
- 3.9.4
- 3.10.1
services:
minio:
# TODO: use official minio/minio image when this issue is fixed:
# https://github.community/t/how-do-i-properly-override-a-service-entrypoint/17435
# Meanwhile, there is a workaround with custom image build with CMD set.
# See hack/minio/Dockerfile
image: hypnoglow/minio:latest
env:
MINIO_ACCESS_KEY: EXAMPLEKEY123
MINIO_SECRET_KEY: EXAMPLESECRET123456
ports:
- 9000:9000
env:
AWS_ENDPOINT: localhost:9000
AWS_ACCESS_KEY_ID: EXAMPLEKEY123
AWS_SECRET_ACCESS_KEY: EXAMPLESECRET123456
AWS_DISABLE_SSL: true
AWS_DEFAULT_REGION: us-east-1
steps:
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
- name: Setup Go
uses: actions/setup-go@268d8c0ca0432bb2cf416faae41297df9d262d7f # v3.3.0
with:
cache: true
go-version-file: 'go.mod'
- name: Download dependencies
run: |
go mod download -x
- name: Install helm
run: |
helm_version="${{ matrix.helm }}"
curl -sSL https://get.helm.sh/helm-v${helm_version}-linux-amd64.tar.gz | tar xz
mv linux-amd64/helm $(go env GOPATH)/bin/helm
rm -rf linux-amd64
# Run `helm init` only for helm v2
if [ "${helm_version:0:1}" == "2" ]; then
helm init --client-only
fi
# Add `stable` repo only for helm v3
if [ "${helm_version:0:1}" == "3" ]; then
helm repo add stable https://charts.helm.sh/stable
fi
- name: Build and install the plugin
run: |
plugin_version="commit.${{ github.sha }}"
tmp_dir="$(mktemp -d)"
go build \
-o bin/helm-s3 \
-ldflags "-X main.version=${plugin_version}" \
./cmd/helm-s3
# Copy plugin directory to outside of the workspace.
cp -r ${{ github.workspace }} ${tmp_dir}
# Correct the plugin manifest to make installation purely local
cd ${tmp_dir}/helm-s3
sed -i "/^hooks:/,+2 d" plugin.yaml
sed -i "s/^version:.*$/version: ${plugin_version}/" plugin.yaml
helm plugin install ${tmp_dir}/helm-s3
- name: Install minio client, prepare minio server
run: |
curl -sSL https://dl.minio.io/client/mc/release/linux-amd64/mc -o $(go env GOPATH)/bin/mc
chmod +x $(go env GOPATH)/bin/mc
mc config host add helm-s3-minio http://${AWS_ENDPOINT} ${AWS_ACCESS_KEY_ID} ${AWS_SECRET_ACCESS_KEY}
mc mb helm-s3-minio/test-bucket
- name: Run tests
run: |
go test -v ./tests/e2e/...
docker-images:
name: Build Docker images
needs:
- test-e2e
uses: ./.github/workflows/reusable-docker-images.yml
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
test-install:
name: Test plugin installation
needs:
- test-e2e
uses: ./.github/workflows/reusable-test-install.yml
if: github.ref_name == 'master'