Merge pull request #449 from hypnoglow/dependabot/github_actions/dock… #604
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: main | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- '*' | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- name: Setup Go | |
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 | |
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@4fe8c5f003fae66aa5ebb77cfd3e7bfbbda0b6b0 # v3.1.5 | |
- name: Run linters | |
uses: golangci/golangci-lint-action@a4f60bb28d35aeee14e6880718e0c85ff1882e64 # v6.0.1 | |
with: | |
version: v1.59.1 | |
args: --verbose | |
- name: Run ShellCheck | |
uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38 # v2.0.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.14.4 | |
- 3.15.2 | |
services: | |
minio: | |
# TODO: use official minio/minio image when this issue is fixed: | |
# https://gh.neting.ccmunity/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@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- name: Setup Go | |
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 | |
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 }} | |
# This job's only purpose is to be used for the "Require status checks to pass | |
# before merging" feature. | |
status-check: | |
name: "Status check" | |
needs: | |
- build | |
- test-e2e | |
- docker-images | |
if: always() | |
runs-on: ubuntu-latest | |
steps: | |
- name: Decide whether the needed jobs succeeded or failed | |
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2 | |
with: | |
jobs: ${{ toJSON(needs) }} | |
test-install: | |
name: Test plugin installation | |
needs: | |
- test-e2e | |
uses: ./.github/workflows/reusable-test-install.yml | |
if: github.ref_name == 'master' |