|
| 1 | +name: Test |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - 'feature/**' |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - main |
| 11 | + |
| 12 | +jobs: |
| 13 | + test: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + container: |
| 17 | + # https://hub.docker.com/r/drevops/ci-runner |
| 18 | + image: drevops/ci-runner:25.9.0@sha256:94e278c994808d966dd28143fe990b19351697a5915a0ab346f39434aec28b27 |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Configure Git safe directory |
| 22 | + run: git config --global --add safe.directory "${GITHUB_WORKSPACE}" |
| 23 | + |
| 24 | + - name: Check out the repo |
| 25 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 |
| 26 | + |
| 27 | + - name: Lint shell scripts |
| 28 | + run: | |
| 29 | + shfmt -i 2 -ci -s -d seed.sh tests/bats/*.bash tests/bats/*.bats |
| 30 | + shellcheck seed.sh tests/bats/*.bash tests/bats/*.bats |
| 31 | + continue-on-error: ${{ vars.CI_LINT_IGNORE_FAILURE == '1' }} |
| 32 | + |
| 33 | + - name: Install goss |
| 34 | + run: curl -fsSL https://goss.rocks/install | sh && goss --version |
| 35 | + |
| 36 | + - name: Build Docker image |
| 37 | + run: docker build -t gosstestorg/gosstestimage:goss-test-tag . |
| 38 | + |
| 39 | + - name: Run Goss tests |
| 40 | + run: | |
| 41 | + export GOSS_FILES_STRATEGY=cp |
| 42 | + export GOSS_PATH=/usr/local/bin/goss |
| 43 | + GOSS_FILES_PATH=tests/dgoss dgoss run -i gosstestorg/gosstestimage:goss-test-tag |
| 44 | + continue-on-error: ${{ vars.CI_TEST_IGNORE_FAILURE == '1' }} |
| 45 | + |
| 46 | + - name: Install BATS dependencies |
| 47 | + run: npm --prefix tests/bats ci |
| 48 | + |
| 49 | + - name: Run BATS tests with code coverage |
| 50 | + run: | |
| 51 | + echo "${DOCKER_PASS}" | docker login --username "${DOCKER_USER}" --password-stdin |
| 52 | + kcov --include-pattern=.sh,.bash --bash-parse-files-in-dir=. --exclude-pattern=vendor,node_modules,coverage $(pwd)/coverage tests/bats/node_modules/.bin/bats tests/bats |
| 53 | + shell: bash |
| 54 | + continue-on-error: ${{ vars.CI_TEST_IGNORE_FAILURE == '1' }} |
| 55 | + env: |
| 56 | + DOCKER_USER: ${{ secrets.DOCKER_USER }} |
| 57 | + DOCKER_PASS: ${{ secrets.DOCKER_PASS }} |
| 58 | + |
| 59 | + - name: Upload coverage report as an artifact |
| 60 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 |
| 61 | + with: |
| 62 | + name: ${{github.job}}-code-coverage-report |
| 63 | + include-hidden-files: true |
| 64 | + path: coverage |
| 65 | + if-no-files-found: error |
| 66 | + |
| 67 | + - name: Upload coverage report to Codecov |
| 68 | + uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5 |
| 69 | + if: ${{ env.CODECOV_TOKEN != '' }} |
| 70 | + with: |
| 71 | + directory: coverage |
| 72 | + fail_ci_if_error: true |
| 73 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 74 | + env: |
| 75 | + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |
| 76 | + |
| 77 | + push-canary-to-registry: |
| 78 | + if: github.event_name == 'push' |
| 79 | + runs-on: ubuntu-latest |
| 80 | + |
| 81 | + needs: |
| 82 | + - test |
| 83 | + |
| 84 | + steps: |
| 85 | + - name: Checkout code |
| 86 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 |
| 87 | + |
| 88 | + - name: Set up QEMU |
| 89 | + uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3 |
| 90 | + |
| 91 | + - name: Set up Docker Buildx |
| 92 | + uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3 |
| 93 | + |
| 94 | + - name: Log in to Docker Hub |
| 95 | + uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3 |
| 96 | + with: |
| 97 | + username: ${{ secrets.DOCKER_USER }} |
| 98 | + password: ${{ secrets.DOCKER_PASS }} |
| 99 | + |
| 100 | + - name: Extract metadata (tags, labels) for Docker |
| 101 | + id: meta |
| 102 | + uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5 |
| 103 | + with: |
| 104 | + images: drevops/mariadb-drupal-data |
| 105 | + |
| 106 | + - name: Build and push Docker image |
| 107 | + uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6 |
| 108 | + with: |
| 109 | + context: . |
| 110 | + push: true |
| 111 | + tags: drevops/mariadb-drupal-data:canary |
| 112 | + labels: ${{ steps.meta.outputs.labels }} |
| 113 | + platforms: linux/amd64,linux/arm64 |
0 commit comments