|
| 1 | +# This is a GitHub workflow defining a set of jobs with a set of steps. |
| 2 | +# ref: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions |
| 3 | +# |
| 4 | +name: Test chart |
| 5 | + |
| 6 | +on: |
| 7 | + pull_request: |
| 8 | + paths: |
| 9 | + - "chart/**" |
| 10 | + - "!**.md" |
| 11 | + - ".github/workflows/test-chart.yml" |
| 12 | + push: |
| 13 | + paths: |
| 14 | + - "chart/**" |
| 15 | + - "!**.md" |
| 16 | + - ".github/workflows/test-chart.yml" |
| 17 | + branches-ignore: |
| 18 | + - "dependabot/**" |
| 19 | + workflow_dispatch: |
| 20 | + |
| 21 | +permissions: |
| 22 | + contents: read |
| 23 | + |
| 24 | +defaults: |
| 25 | + run: |
| 26 | + working-directory: chart |
| 27 | + |
| 28 | +jobs: |
| 29 | + lint-templates: |
| 30 | + runs-on: ubuntu-22.04 |
| 31 | + |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@v3 |
| 34 | + - uses: actions/setup-python@v4 |
| 35 | + with: |
| 36 | + python-version: "3.x" |
| 37 | + |
| 38 | + - name: Install dependencies (yamllint) |
| 39 | + run: pip install yamllint |
| 40 | + |
| 41 | + - run: helm dependency update |
| 42 | + |
| 43 | + - name: helm lint |
| 44 | + run: | |
| 45 | + helm lint . \ |
| 46 | + --values dev-values.yaml |
| 47 | +
|
| 48 | + - name: helm template |
| 49 | + run: | |
| 50 | + helm template . \ |
| 51 | + --values dev-values.yaml \ |
| 52 | + --output-dir rendered-templates |
| 53 | +
|
| 54 | + - name: yamllint (only on templates we manage) |
| 55 | + run: | |
| 56 | + rm -rf rendered-templates/mastodon/charts |
| 57 | +
|
| 58 | + yamllint rendered-templates \ |
| 59 | + --config-data "{rules: {indentation: {spaces: 2}, line-length: disable}}" |
| 60 | +
|
| 61 | + # This job helps us validate that rendered templates are valid k8s resources |
| 62 | + # against a k8s api-server, via "helm template --validate", but also that a |
| 63 | + # basic configuration can be used to successfully startup mastodon. |
| 64 | + # |
| 65 | + test-install: |
| 66 | + runs-on: ubuntu-22.04 |
| 67 | + timeout-minutes: 15 |
| 68 | + |
| 69 | + strategy: |
| 70 | + fail-fast: false |
| 71 | + matrix: |
| 72 | + include: |
| 73 | + # k3s-channel reference: https://update.k3s.io/v1-release/channels |
| 74 | + - k3s-channel: latest |
| 75 | + - k3s-channel: stable |
| 76 | + |
| 77 | + # This represents the oldest configuration we test against. |
| 78 | + # |
| 79 | + # The k8s version chosen is based on the oldest still supported k8s |
| 80 | + # version among two managed k8s services, GKE, EKS. |
| 81 | + # - GKE: https://endoflife.date/google-kubernetes-engine |
| 82 | + # - EKS: https://endoflife.date/amazon-eks |
| 83 | + # |
| 84 | + # The helm client's version can influence what helper functions is |
| 85 | + # available for use in the templates, currently we need v3.6.0 or |
| 86 | + # higher. |
| 87 | + # |
| 88 | + - k3s-channel: v1.21 |
| 89 | + helm-version: v3.6.0 |
| 90 | + |
| 91 | + steps: |
| 92 | + - uses: actions/checkout@v3 |
| 93 | + |
| 94 | + # This action starts a k8s cluster with NetworkPolicy enforcement and |
| 95 | + # installs both kubectl and helm. |
| 96 | + # |
| 97 | + # ref: https://github.com/jupyterhub/action-k3s-helm#readme |
| 98 | + # |
| 99 | + - uses: jupyterhub/action-k3s-helm@v3 |
| 100 | + with: |
| 101 | + k3s-channel: ${{ matrix.k3s-channel }} |
| 102 | + helm-version: ${{ matrix.helm-version }} |
| 103 | + metrics-enabled: false |
| 104 | + traefik-enabled: false |
| 105 | + docker-enabled: false |
| 106 | + |
| 107 | + - run: helm dependency update |
| 108 | + |
| 109 | + # Validate rendered helm templates against the k8s api-server |
| 110 | + - name: helm template --validate |
| 111 | + run: | |
| 112 | + helm template --validate mastodon . \ |
| 113 | + --values dev-values.yaml |
| 114 | +
|
| 115 | + - name: helm install |
| 116 | + run: | |
| 117 | + helm install mastodon . \ |
| 118 | + --values dev-values.yaml \ |
| 119 | + --timeout 10m |
| 120 | +
|
| 121 | + # This actions provides a report about the state of the k8s cluster, |
| 122 | + # providing logs etc on anything that has failed and workloads marked as |
| 123 | + # important. |
| 124 | + # |
| 125 | + # ref: https://github.com/jupyterhub/action-k8s-namespace-report#readme |
| 126 | + # |
| 127 | + - name: Kubernetes namespace report |
| 128 | + uses: jupyterhub/action-k8s-namespace-report@v1 |
| 129 | + if: always() |
| 130 | + with: |
| 131 | + important-workloads: >- |
| 132 | + deploy/mastodon-sidekiq |
| 133 | + deploy/mastodon-streaming |
| 134 | + deploy/mastodon-web |
| 135 | + job/mastodon-assets-precompile |
| 136 | + job/mastodon-chewy-upgrade |
| 137 | + job/mastodon-create-admin |
| 138 | + job/mastodon-db-migrate |
0 commit comments