diff --git a/.github/actions/entrypoint.sh b/.github/actions/entrypoint.sh new file mode 100755 index 00000000..b40eadde --- /dev/null +++ b/.github/actions/entrypoint.sh @@ -0,0 +1,21 @@ +#!/bin/sh -l + +if [ $1 == "validate" ]; then + echo "validating helm charts" + helm dependency update $2 + helm lint --strict $2 + helm template $2 + +elif [ $1 == "publish" ]; then + CHART_VERSION=$(echo ${GITHUB_REF} | cut -d/ -f 3) + CHART_NAME=$(awk '/^name:/ {print $2}' $2/Chart.yaml) + INPUT_REPOSITORY=${{ inputs.helm-gcs-repository }} + INPUT_CREDENTIALS=${{ inputs.helm-gcs-credentials }} + export GOOGLE_APPLICATION_CREDENTIALS=${HOME}/helm-gcs-key.json + + echo ${INPUT_CREDENTIALS:-$HELM_GCS_CREDENTIALS} > ${GOOGLE_APPLICATION_CREDENTIALS} + helm dependency update $2 + helm repo add helm-gcs ${INPUT_REPOSITORY:-$HELM_GCS_REPOSITORY} + helm package --version ${CHART_VERSION} --app-version ${CHART_VERSION} $2 + helm gcs push ${CHART_NAME}-${CHART_VERSION}.tgz helm-gcs --public --retry +fi \ No newline at end of file diff --git a/.github/actions/gradle/action.yml b/.github/actions/gradle/action.yml new file mode 100644 index 00000000..7539ecf8 --- /dev/null +++ b/.github/actions/gradle/action.yml @@ -0,0 +1,10 @@ +name: 'Gradle command action' +inputs: + args: + required: true +runs: + using: "composite" + steps: + - run: | + ./gradlew ${{ inputs.args }} --info --max-workers=2 -Dorg.gradle.jvmargs=-Xmx2g -Dorg.gradle.console=plain --continue + shell: bash \ No newline at end of file diff --git a/.github/actions/helm.dockerfile b/.github/actions/helm.dockerfile new file mode 100644 index 00000000..c6170b95 --- /dev/null +++ b/.github/actions/helm.dockerfile @@ -0,0 +1,23 @@ +FROM ghcr.io/openzipkin/alpine:3.12.1 + +# Use latest recommended version here +ARG HELM_VERSION=3.4.2 + +WORKDIR /usr/local/bin + +# Install Helm, helm-gcs plugin, git and openssh-client +RUN apk --update --no-cache add curl git openssh-client && \ + curl -sSL https://get.helm.sh/helm-v${HELM_VERSION}-linux-amd64.tar.gz | tar xz \ + --strip=1 linux-amd64/helm && \ + helm plugin install https://github.com/hayorov/helm-gcs.git --version 0.3.6 && \ + apk del curl --purge && \ + rm -rf ~/.cache ~/.local/share/helm/plugins/helm-gcs.git/.git && \ + helm version && helm plugin list + +ENV HELM_PLUGINS=/root/.local/share/helm/plugins + +# Copies your code file from your action repository to the filesystem path `/` of the container +COPY entrypoint.sh /entrypoint.sh + +# Code file to execute when the docker container starts up (`entrypoint.sh`) +ENTRYPOINT ["/entrypoint.sh"] diff --git a/.github/actions/validate-charts/action.yml b/.github/actions/validate-charts/action.yml new file mode 100644 index 00000000..53d5ff89 --- /dev/null +++ b/.github/actions/validate-charts/action.yml @@ -0,0 +1,13 @@ +name: 'Validate helm charts' +description: 'prevalidate helm chart template before its deployment; executes helm lint and helm template commands' +inputs: + chart-path: + description: 'Path to helm chart directory' + required: true + default: './helm' +runs: + using: 'docker' + image: '../helm.dockerfile' + args: + - validate + - ${{ inputs.chart-path }} \ No newline at end of file diff --git a/.github/workflows/pr-test.yml b/.github/workflows/pr-test.yml index d3d790d3..90be9306 100644 --- a/.github/workflows/pr-test.yml +++ b/.github/workflows/pr-test.yml @@ -29,7 +29,10 @@ jobs: gradle-packages-${{ runner.os }} - name: Unit test - run: ./gradlew jacocoTestReport + uses: hypertrace/github-actions/gradle@main + with: + args: jacocoTestReport + - name: Upload coverage to Codecov uses: codecov/codecov-action@v1 @@ -39,21 +42,46 @@ jobs: flags: unit - name: Integration test - run: ./gradlew jacocoIntegrationTestReport - + uses: hypertrace/github-actions/gradle@main + with: + args: jacocoIntegrationTestReport - name: Upload coverage to Codecov uses: codecov/codecov-action@v1 with: name: integration test reports fail_ci_if_error: true flags: integration - - - name: Copy test reports - run: ./gradlew copyAllReports --output-dir=/tmp/test-reports + + - name: copy test reports + uses: hypertrace/github-actions/gradle@main + with: + args: copyAllReports --output-dir=/tmp/test-reports - name: Archive test reports uses: actions/upload-artifact@v1 with: name: test-reports path: /tmp/test-reports - if: ${{ always() }} + if: always() + + - name: Publish Unit Test Results + uses: docker://ghcr.io/enricomi/publish-unit-test-result-action:v1.6 + if: always() + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + files: ./**/build/test-results/**/*.xml + + validate-helm-charts: + runs-on: ubuntu-20.04 + steps: + - name: Check out code + uses: actions/checkout@v2.3.4 + with: + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + fetch-depth: 0 + + - name: validate charts + uses: hypertrace/github-actions/gradle@main + + \ No newline at end of file