|
| 1 | +name: Lint and Test Charts |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + tags: |
| 8 | + - '*' |
| 9 | + paths: |
| 10 | + # Only run test and docker publish if some code have changed |
| 11 | + - 'deployment/k8s/charts/**' |
| 12 | + - '.github/workflows/check_charts.yaml' |
| 13 | + - 'pyproject.toml' |
| 14 | + pull_request: |
| 15 | + |
| 16 | +jobs: |
| 17 | + lint-test: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - name: Checkout |
| 21 | + uses: actions/checkout@v4 |
| 22 | + with: |
| 23 | + fetch-depth: 0 |
| 24 | + |
| 25 | + # - name: Check Version |
| 26 | + # run: | |
| 27 | + # current_version=$(grep '^version=' pyproject.toml | cut -f2 -d= | tr -d ' ' | tr -d '"') |
| 28 | + # app_version=$(grep 'appVersion:' deployment/k8s/charts/Chart.yaml | cut -f2 -d: | tr -d ' ') |
| 29 | + # if [[ "$current_version" != "$app_version" ]]; then |
| 30 | + # echo "❌ current version from pyproject.toml ($current_version) and appVersion from Chart.yaml ($app_version) differs"; |
| 31 | + # exit 1; |
| 32 | + # fi |
| 33 | + |
| 34 | + - name: Set up Helm |
| 35 | + uses: azure/setup-helm@v4 |
| 36 | + with: |
| 37 | + version: v3.9.2 |
| 38 | + |
| 39 | + - uses: actions/setup-python@v5 |
| 40 | + with: |
| 41 | + python-version: '3.x' |
| 42 | + |
| 43 | + - name: Set up chart-testing |
| 44 | + |
| 45 | + |
| 46 | + - name: Run chart-testing (list-changed) |
| 47 | + id: list-changed |
| 48 | + run: | |
| 49 | + changed=$(ct list-changed --chart-dirs deployment/k8s --target-branch ${{ github.event.repository.default_branch }}) |
| 50 | + if [[ -n "$changed" ]]; then |
| 51 | + echo "::set-output name=changed::true" |
| 52 | + fi |
| 53 | +
|
| 54 | + - name: Run chart-testing (lint) |
| 55 | + run: ct lint --chart-dirs deployment/k8s --target-branch ${{ github.event.repository.default_branch }} |
| 56 | + |
| 57 | + - name: Build container |
| 58 | + uses: docker/build-push-action@v6 |
| 59 | + if: steps.list-changed.outputs.changed == 'true' |
| 60 | + with: |
| 61 | + # See https://github.com/developmentseed/titiler/discussions/387 |
| 62 | + platforms: linux/amd64 |
| 63 | + context: . |
| 64 | + file: Dockerfile |
| 65 | + push: false |
| 66 | + tags: "titiler:dev" |
| 67 | + |
| 68 | + - name: Create kind cluster |
| 69 | + |
| 70 | + if: steps.list-changed.outputs.changed == 'true' |
| 71 | + |
| 72 | + - name: Load container image in kind cluster |
| 73 | + run: kind load docker-image titiler:dev --name chart-testing |
| 74 | + if: steps.list-changed.outputs.changed == 'true' |
| 75 | + |
| 76 | + - name: Run chart-testing (install) |
| 77 | + run: ct install --chart-dirs deployment/k8s |
| 78 | + if: steps.list-changed.outputs.changed == 'true' |
0 commit comments