|
| 1 | +name: tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - release-v* |
| 8 | + - feat-tests |
| 9 | + pull_request: |
| 10 | + branches: |
| 11 | + - main |
| 12 | + |
| 13 | +jobs: |
| 14 | + generate-checks: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - name: Checkout |
| 18 | + uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + fetch-depth: 0 |
| 21 | + - uses: actions/setup-go@v5 |
| 22 | + with: |
| 23 | + go-version: '1.22' |
| 24 | + - uses: actions/cache@v4 |
| 25 | + with: |
| 26 | + path: | |
| 27 | + ~/go/pkg/mod |
| 28 | + ~/.cache/go-build |
| 29 | + key: generate-check-go-${{ runner.os }}-${{ hashFiles('**/go.sum') }} |
| 30 | + restore-keys: | |
| 31 | + generate-check-go-${{ runner.os }}- |
| 32 | + - name: Verify generated source is up-to-date |
| 33 | + run: | |
| 34 | + make generate |
| 35 | + if [ ! -z "$(git status --porcelain)" ]; then |
| 36 | + echo "make generate must be invoked and the result committed" |
| 37 | + git status |
| 38 | + git diff |
| 39 | + exit 1 |
| 40 | + fi |
| 41 | + - name: Verify generated manifests are up-to-date |
| 42 | + run: | |
| 43 | + make manifests |
| 44 | + if [ ! -z "$(git status --porcelain)" ]; then |
| 45 | + echo "make manifests must be invoked and the result committed" |
| 46 | + git status |
| 47 | + git diff |
| 48 | + exit 1 |
| 49 | + fi |
| 50 | + - name: Verify generated api-docs are up-to-date |
| 51 | + run: | |
| 52 | + make api-docs |
| 53 | + if [ ! -z "$(git status --porcelain)" ]; then |
| 54 | + echo "make api-docs must be invoked and the result committed" |
| 55 | + git status |
| 56 | + git diff |
| 57 | + exit 1 |
| 58 | + fi |
| 59 | + - name: Verify go.mod and go.sum are clean |
| 60 | + run: | |
| 61 | + go mod tidy |
| 62 | + if [ ! -z "$(git status --porcelain)" ]; then |
| 63 | + echo "go mod tidy must be invoked and the result committed" |
| 64 | + git status |
| 65 | + git diff |
| 66 | + exit 1 |
| 67 | + fi |
| 68 | +
|
| 69 | + check-docker-images: |
| 70 | + strategy: |
| 71 | + matrix: |
| 72 | + include: |
| 73 | + - docker_platform: linux/amd64 |
| 74 | + goarch: amd64 |
| 75 | + - docker_platform: linux/arm64 |
| 76 | + goarch: arm64 |
| 77 | + fail-fast: false |
| 78 | + runs-on: ubuntu-latest |
| 79 | + name: check-docker-images-${{ matrix.docker_platform }} |
| 80 | + steps: |
| 81 | + - name: Checkout |
| 82 | + uses: actions/checkout@v4 |
| 83 | + - uses: actions/setup-go@v5 |
| 84 | + with: |
| 85 | + go-version: '1.22' |
| 86 | + - uses: actions/cache@v4 |
| 87 | + with: |
| 88 | + path: | |
| 89 | + ~/go/pkg/mod |
| 90 | + ~/.cache/go-build |
| 91 | + key: check-docker-images-${{ matrix.docker_platform }}-${{ hashFiles('**/go.sum') }} |
| 92 | + restore-keys: | |
| 93 | + check-docker-images-${{ runner.os }}- |
| 94 | + - name: Setup QEMU |
| 95 | + uses: docker/setup-qemu-action@v3 |
| 96 | + - name: Setup Docker Buildx |
| 97 | + id: buildx |
| 98 | + uses: docker/setup-buildx-action@v3 |
| 99 | + - name: Build template-controller |
| 100 | + run: | |
| 101 | + GOARCH=${{ matrix.goarch }} make build |
| 102 | + - name: Build docker images |
| 103 | + run: | |
| 104 | + docker build -t test-image --platform=${{ matrix.docker_platform }} . |
| 105 | + - name: Test if git works inside container |
| 106 | + run: | |
| 107 | + # test if the git binary is still working, which keep breaking due to wolfi-base updates being missed |
| 108 | + # If you see this failing, it's time to upgrade the base image in Dockerfile... |
| 109 | + docker run --platform=${{ matrix.docker_platform }} --rm -i --entrypoint=/bin/sh test-image -c "cd && git clone https://github.com/kluctl/kluctl.git" |
| 110 | +
|
| 111 | + tests: |
| 112 | + runs-on: ubuntu-22.04 |
| 113 | + name: tests |
| 114 | + steps: |
| 115 | + - name: Checkout |
| 116 | + uses: actions/checkout@v4 |
| 117 | + - uses: actions/setup-go@v5 |
| 118 | + with: |
| 119 | + go-version: '1.22' |
| 120 | + - uses: actions/setup-python@v5 |
| 121 | + with: |
| 122 | + python-version: '3.11' |
| 123 | + - uses: actions/cache@v4 |
| 124 | + with: |
| 125 | + path: | |
| 126 | + ~/go/pkg/mod |
| 127 | + ~/.cache/go-build |
| 128 | + key: tests-go-${{ runner.os }}-${{ hashFiles('**/go.sum') }} |
| 129 | + restore-keys: | |
| 130 | + tests-go-${{ runner.os }}- |
| 131 | + - name: Run tests |
| 132 | + shell: bash |
| 133 | + run: | |
| 134 | + make test |
0 commit comments