diff --git a/.github/runs-on.yml b/.github/runs-on.yml new file mode 100644 index 0000000..b1bfde5 --- /dev/null +++ b/.github/runs-on.yml @@ -0,0 +1 @@ +_extends: .github-private diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 710bcd2..27fad00 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -11,7 +11,7 @@ permissions: jobs: release-please: - runs-on: ubuntu-latest + runs-on: runs-on=${{ github.run_id }}/runner=evertrust steps: - uses: googleapis/release-please-action@v4 id: release @@ -21,27 +21,26 @@ jobs: release_created: ${{ steps.release.outputs.release_created }} release: - runs-on: ubuntu-22.04 - needs: release-please - if: ${{ needs.release-please.outputs.release_created }} - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Install Helm - uses: azure/setup-helm@v3 - - - name: Build chart - run: | - helm repo add bitnami https://charts.bitnami.com/bitnami - helm dependencies build - helm package . - - - name: Upload to Sonatype repo - env: - NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }} - NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} - run: | - PACKAGE="$(find . -type f -name 'stream-*.tgz' -maxdepth 1 | head -n 1)" - curl -F file=@$PACKAGE --user "$NEXUS_USERNAME:$NEXUS_PASSWORD" --fail https://repo.evertrust.io/service/rest/v1/components?repository=charts + runs-on: runs-on=${{ github.run_id }}/runner=evertrust + needs: release-please + if: ${{ needs.release-please.outputs.release_created }} + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install Helm + uses: azure/setup-helm@v3 + + - name: Build chart + run: | + helm repo add bitnami https://charts.bitnami.com/bitnami + helm dependencies build + helm package . + - name: Upload to Sonatype repo + env: + NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }} + NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} + run: | + PACKAGE="$(find . -type f -name 'stream-*.tgz' -maxdepth 1 | head -n 1)" + curl -F file=@$PACKAGE --user "$NEXUS_USERNAME:$NEXUS_PASSWORD" --fail https://repo.evertrust.io/service/rest/v1/components?repository=charts diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..1537677 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,18 @@ +name: Test + +on: + pull_request: + workflow_dispatch: + +jobs: + test: + runs-on: runs-on=${{ github.run_id }}/runner=evertrust + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install Helm + uses: azure/setup-helm@v3 + + - name: Test chart + run: make test diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 216f69e..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,41 +0,0 @@ -image: - name: alpine/helm:3.7.2 - entrypoint: ["/bin/sh", "-c"] - -stages: - - init - - package - - upload - -dependencies: - stage: init - script: - - helm repo add bitnami https://charts.bitnami.com/bitnami - - helm dependencies build - only: - variables: - - $CI_COMMIT_TAG - artifacts: - paths: - - charts/ - -package: - stage: package - script: - - helm package . - only: - variables: - - $CI_COMMIT_TAG - artifacts: - paths: - - stream-*.tgz - -upload: - stage: upload - script: - - apk add curl - - PACKAGE="$(find . -type f -name 'stream-*.tgz' -maxdepth 1 | head -n 1)" - - curl -F file=@$PACKAGE --user "$NEXUS_USERNAME:$NEXUS_PASSWORD" https://repo.evertrust.io/service/rest/v1/components?repository=charts - only: - variables: - - $CI_COMMIT_TAG diff --git a/.helmignore b/.helmignore index f97819a..a90bba8 100644 --- a/.helmignore +++ b/.helmignore @@ -23,4 +23,6 @@ .vscode/ # Dev value files values.*.yml -/*.tgz \ No newline at end of file +/*.tgz +# Helm tests +tests/ \ No newline at end of file diff --git a/Makefile b/Makefile index 01ed41b..1a7c9c2 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,21 @@ -all: gen-schema package +all: gen-schema dependencies package test setup-unittest gen-schema: readme-generator -r README.md -v values.yaml -s values.schema.json -package: - helm dependencies build +dependencies: + helm dependencies build . + +package: dependencies helm package . + +test: setup-unittest + helm unittest . -v tests/values.yaml + +setup-unittest: + @if ! helm plugin list | grep -q "unittest"; then \ + echo "Installing helm unittest plugin..."; \ + helm plugin install https://github.com/helm-unittest/helm-unittest.git; \ + else \ + echo "helm unittest plugin already installed"; \ + fi \ No newline at end of file diff --git a/tests/config_test.yaml b/tests/config_test.yaml new file mode 100644 index 0000000..608dea4 --- /dev/null +++ b/tests/config_test.yaml @@ -0,0 +1,42 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json +suite: configuration features +templates: + - deployment.yml + - config.yml +tests: + - it: should properly configure extraConfig when provided + set: + extraConfig: | + Hello + template: config.yml + asserts: + - isKind: + of: ConfigMap + - matchRegex: + path: data["application.conf"] + pattern: ".*Hello.*" + + - it: should properly mount custom startup scripts via extraVolumes and extraVolumeMounts + set: + extraVolumes: + - name: horizon-entrypoint-scripts + configMap: + name: horizon-entrypoint-scripts + extraVolumeMounts: + - name: horizon-entrypoint-scripts + mountPath: /docker-entrypoint.d/ + template: deployment.yml + asserts: + - isKind: + of: Deployment + - contains: + path: spec.template.spec.volumes + content: + name: horizon-entrypoint-scripts + configMap: + name: horizon-entrypoint-scripts + - contains: + path: spec.template.spec.containers[0].volumeMounts + content: + name: horizon-entrypoint-scripts + mountPath: /docker-entrypoint.d/ diff --git a/tests/values.yaml b/tests/values.yaml new file mode 100644 index 0000000..8049b00 --- /dev/null +++ b/tests/values.yaml @@ -0,0 +1,7 @@ +license: + secretKey: "test" + secretName: "test" + +keyset: + secretKey: "test" + secretName: "test"