|
9 | 9 | required: true |
10 | 10 |
|
11 | 11 | jobs: |
12 | | - # Note: assumes being called in a workflow where build has already run and |
13 | | - # required artifacts have been uploaded |
14 | | - build-test-publish: |
| 12 | + build-and-test: |
15 | 13 | permissions: |
16 | 14 | contents: read |
17 | | - packages: write |
18 | 15 | runs-on: ubuntu-latest |
| 16 | + strategy: |
| 17 | + matrix: |
| 18 | + distribution: [kind, minikube, microk8s, k3s] |
| 19 | + outputs: |
| 20 | + release_version: ${{ steps.set_version.outputs.RELEASE_VERSION }} |
19 | 21 | steps: |
20 | 22 | - uses: actions/checkout@v4 |
21 | 23 |
|
22 | 24 | - name: Set RELEASE_VERSION env var |
| 25 | + id: set_version |
23 | 26 | run: | |
24 | 27 | if [[ "${{ startsWith(inputs.ref, 'refs/tags/v')}}" == "true" ]]; then |
25 | | - echo "RELEASE_VERSION=$(echo -n ${{ inputs.ref }} | cut -d '/' -f 3)" >> $GITHUB_ENV |
| 28 | + RELEASE_VERSION=$(echo -n ${{ inputs.ref }} | cut -d '/' -f 3) |
26 | 29 | else |
27 | | - echo "RELEASE_VERSION=$(date +%Y%m%d-%H%M%S)-g$(git rev-parse --short HEAD)" >> $GITHUB_ENV |
| 30 | + RELEASE_VERSION=$(date +%Y%m%d-%H%M%S)-g$(git rev-parse --short HEAD) |
28 | 31 | fi |
| 32 | + echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV |
| 33 | + echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_OUTPUT |
29 | 34 |
|
30 | 35 | - uses: actions/download-artifact@v4 |
31 | 36 | with: |
32 | 37 | path: _artifacts |
33 | 38 |
|
34 | | - # Setup buildx to build multiarch image: https://github.com/docker/build-push-action/blob/master/docs/advanced/multi-platform.md |
35 | 39 | - name: Set up QEMU |
36 | 40 | uses: docker/setup-qemu-action@v3 |
37 | 41 |
|
38 | 42 | - name: Setup buildx |
39 | 43 | uses: docker/setup-buildx-action@v3 |
40 | 44 |
|
41 | | - # Build and extract node-installer image |
42 | 45 | - name: Extract musl artifacts into ./node-installer/.tmp/linux/(amd64|arm64) dir |
43 | 46 | run: | |
44 | 47 | mkdir -p ./node-installer/.tmp/linux/amd64 |
45 | 48 | mkdir -p ./node-installer/.tmp/linux/arm64 |
46 | 49 | for f in ./_artifacts/*/*-x86_64.tar.gz; do tar -xf $f --directory ./node-installer/.tmp/linux/amd64; done |
47 | 50 | for f in ./_artifacts/*/*-aarch64.tar.gz; do tar -xf $f --directory ./node-installer/.tmp/linux/arm64; done |
48 | 51 |
|
49 | | - # Build local image for testing |
50 | 52 | - name: Build node-installer image for testing |
51 | 53 | run: make build-dev-installer-image |
52 | 54 | working-directory: node-installer |
53 | 55 |
|
54 | | - # Install kind for integration testing |
55 | | - - name: Install kind |
56 | | - |
| 56 | + |
| 57 | + if: matrix.distribution == 'kind' |
57 | 58 | with: |
58 | 59 | install_only: true |
59 | | - |
60 | | - # Run the integration test |
61 | | - - name: Run integration test |
62 | | - run: ./integration-test.sh |
| 60 | + |
| 61 | + |
| 62 | + if: matrix.distribution == 'minikube' |
| 63 | + |
| 64 | + |
| 65 | + if: matrix.distribution == 'microk8s' |
| 66 | + |
| 67 | + - name: Run KIND test |
| 68 | + if: matrix.distribution == 'kind' |
| 69 | + run: make test-kind |
63 | 70 | working-directory: node-installer |
64 | 71 |
|
65 | | - # Login to registry and publish if tests pass |
| 72 | + - name: Run MiniKube test |
| 73 | + if: matrix.distribution == 'minikube' |
| 74 | + run: make test-minikube |
| 75 | + working-directory: node-installer |
| 76 | + |
| 77 | + - name: Run MicroK8s test |
| 78 | + if: matrix.distribution == 'microk8s' |
| 79 | + run: make test-microk8s |
| 80 | + working-directory: node-installer |
| 81 | + |
| 82 | + - name: Run K3s test |
| 83 | + if: matrix.distribution == 'k3s' |
| 84 | + run: make test-k3s |
| 85 | + working-directory: node-installer |
| 86 | + |
| 87 | + publish: |
| 88 | + needs: build-and-test |
| 89 | + permissions: |
| 90 | + contents: read |
| 91 | + packages: write |
| 92 | + runs-on: ubuntu-latest |
| 93 | + steps: |
| 94 | + - uses: actions/checkout@v4 |
| 95 | + |
| 96 | + - uses: actions/download-artifact@v4 |
| 97 | + with: |
| 98 | + path: _artifacts |
| 99 | + |
| 100 | + - name: Set up QEMU |
| 101 | + uses: docker/setup-qemu-action@v3 |
| 102 | + |
| 103 | + - name: Setup buildx |
| 104 | + uses: docker/setup-buildx-action@v3 |
| 105 | + |
| 106 | + - name: Extract musl artifacts into ./node-installer/.tmp/linux/(amd64|arm64) dir |
| 107 | + run: | |
| 108 | + mkdir -p ./node-installer/.tmp/linux/amd64 |
| 109 | + mkdir -p ./node-installer/.tmp/linux/arm64 |
| 110 | + for f in ./_artifacts/*/*-x86_64.tar.gz; do tar -xf $f --directory ./node-installer/.tmp/linux/amd64; done |
| 111 | + for f in ./_artifacts/*/*-aarch64.tar.gz; do tar -xf $f --directory ./node-installer/.tmp/linux/arm64; done |
| 112 | +
|
66 | 113 | - name: Login to GitHub container registry |
67 | 114 | uses: docker/login-action@v3 |
68 | 115 | with: |
|
75 | 122 | with: |
76 | 123 | push: true |
77 | 124 | tags: | |
78 | | - ghcr.io/${{ github.repository }}/node-installer:${{ env.RELEASE_VERSION }} |
| 125 | + ghcr.io/${{ github.repository }}/node-installer:${{ needs.build-and-test.outputs.release_version }} |
79 | 126 | context: node-installer |
80 | 127 | platforms: linux/amd64,linux/arm64 |
81 | 128 |
|
|
0 commit comments