name: "Apps: Tests" on: pull_request: branches: - '**' tags-ignore: - '**' paths: - 'charts/**' - '.github/workflows/apps.test.yaml' - '.github/ct-install.yaml' - '.github/ct-lint.yaml' jobs: changes: name: Get changed Apps runs-on: ubuntu-20.04 outputs: matrix: "{\"app\": ${{ steps.reduce.outputs.apps }} }" empty_matrix: ${{ steps.reduce.outputs.empty_matrix }} steps: - name: Checkout uses: actions/checkout@v2 - uses: dorny/paths-filter@v2 id: filter with: list-files: json filters: | changed: - 'charts/dev/**' - 'charts/stable/**' - 'charts/incubator/**' - 'charts/dependency/**' - 'charts/library/**' - 'charts/core/**' - run: echo '${{ toJson(steps.filter.outputs) }}' > changes.json - id: reduce run: | APPS=$(jq --raw-output '.changed_files | fromjson | .[] |= sub("(?(?(?[\/]?)[^\/]+\/)(?(?[\/]?)[^\/]+\/)(?(?[\/]?)[^\/]+)(?.+))"; "\(.third_directory)") | unique' changes.json) echo ::set-output name=apps::${APPS} if [ -z "${APPS[0]}" ]; then echo "No Changed Apps" echo "::set-output name=empty_matrix::true" else echo "Changed Apps: ${APPS[*]}" echo "::set-output name=empty_matrix::false" fi app-tests: needs: [changes] if: ${{ needs.changes.outputs.empty_matrix == 'false' }} name: App Tests runs-on: ubuntu-20.04 strategy: matrix: ${{ fromJson(needs.changes.outputs.matrix) }} fail-fast: false steps: ## # GENERAL SECTION ## - name: Checkout if: ${{ matrix.app != '.gitkee' }} uses: actions/checkout@v2 with: fetch-depth: 0 - name: Cache helm repo cache id: cache uses: actions/cache@v2 with: key: helmrepocache-${{ github.sha }} path: | ~/.cache/helm/repository ~/.config/helm/repositories.yaml - name: Prepare-Lint if: ${{ matrix.app != '.gitkee' }} id: prep-lint run: | if test -f "./charts/incubator/${{ matrix.app }}/Chart.yaml"; then train="incubator" elif test -f "./charts/stable/${{ matrix.app }}/Chart.yaml"; then train="stable" elif test -f "./charts/library/${{ matrix.app }}/Chart.yaml"; then train="library" elif test -f "./charts/dev/${{ matrix.app }}/Chart.yaml"; then train="dev" elif test -f "./charts/dependency/${{ matrix.app }}/Chart.yaml"; then train="dependency" elif test -f "./charts/core/${{ matrix.app }}/Chart.yaml"; then train="core" else train="incubator" fi echo ::set-output name=train::${train} if test -f "./charts/${train}/${{ matrix.app }}/SKIPINSTALL"; then install='false' echo "::set-output name=install::false" else install="true" echo "::set-output name=install::true" fi sudo groupadd apps -g 568 sudo useradd apps -u 568 -g 568 -d /home/apps -s /bin/bash - name: Install Helm if: ${{ matrix.app != '.gitkee' }} uses: azure/setup-helm@v1 with: version: v3.5.3 - name: update helm repo cache run: | helm repo add truecharts https://truecharts.org helm repo add bitnami https://charts.bitnami.com/bitnami helm repo add metallb https://metallb.github.io/metallb helm repo update - uses: actions/setup-python@v2 if: ${{ matrix.app != '.gitkee' }} with: python-version: 3.7 - name: Set up chart-testing if: ${{ matrix.app != '.gitkee' }} uses: helm/chart-testing-action@v2.1.0 ## # Chart-Testing Section ## - name: Run chart-testing (lint) if: ${{ matrix.app != 'common' && matrix.app != '.gitkee' }} id: lint run: ct lint --config .github/ct-lint.yaml --charts 'charts/${{ steps.prep-lint.outputs.train }}/${{ matrix.app }}' - name: Create k3d cluster if: ${{ matrix.app != 'common' && matrix.app != '.gitkee' && steps.prep-lint.outputs.install != 'false' }} uses: nolar/setup-k3d-k3s@v1 with: version: v1.22.2+k3s1 ## TODO: Fix common-test - name: Run chart-testing (install) if: ${{ matrix.app != 'common' && matrix.app != '.gitkee' && steps.prep-lint.outputs.install != 'false' }} run: ct install --config .github/ct-install.yaml --charts 'charts/${{ steps.prep-lint.outputs.train }}/${{ matrix.app }}' app-tests-complete: needs: [app-tests] name: Apps Test Complete runs-on: ubuntu-latest steps: - name: complete message run: echo "App Tests Completed Successfully" release-test: runs-on: ubuntu-latest container: image: ghcr.io/truecharts/devcontainer:v2.0.2 steps: - name: Cache helm repo cache id: cache uses: actions/cache@v2 with: key: helmrepocache-${{ github.sha }} path: | ~/.cache/helm/repository ~/.config/helm/repositories.yaml - uses: actions/checkout@v2 name: Checkout with: fetch-depth: 100 - name: Checkout uses: actions/checkout@v2 with: repository: truecharts/catalog path: catalog - name: build-and-run run: | tools/build-release.sh --config .github/cr.yaml