|
| 1 | +--- |
| 2 | +name: ci |
| 3 | + |
| 4 | +on: |
| 5 | + # Run on all PRs |
| 6 | + pull_request: |
| 7 | + |
| 8 | +env: |
| 9 | + GH_TOKEN: ${{ github.token }} |
| 10 | + HELM_VERSION: v3.14.4 |
| 11 | + PYTHON_VERSION: 3.13 |
| 12 | + POSTGRES_PASSWORD: postgres |
| 13 | + UV_VERSION: 0.5.3 |
| 14 | + TOPAZ_VERSION: 0.32.36 |
| 15 | + |
| 16 | +jobs: |
| 17 | + lint: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - |
| 21 | + uses: actions/checkout@v4 |
| 22 | + with: |
| 23 | + # Fetch the full history so that we can diff against the target branch |
| 24 | + fetch-depth: 0 |
| 25 | + - |
| 26 | + name: Set up Helm |
| 27 | + uses: azure/setup-helm@v4 |
| 28 | + with: |
| 29 | + version: ${{ env.HELM_VERSION }} |
| 30 | + - |
| 31 | + uses: actions/setup-python@v5 |
| 32 | + with: |
| 33 | + python-version: ${{ env.PYTHON_VERSION }} |
| 34 | + check-latest: true |
| 35 | + - |
| 36 | + name: Set up chart-testing |
| 37 | + uses: helm/chart-testing-action@v2.6.0 |
| 38 | + with: |
| 39 | + version: v3.10.0 |
| 40 | + - |
| 41 | + name: Lint |
| 42 | + run: | |
| 43 | + ct lint --config ct.yaml --helm-repo-extra-args "aserto-helm=-u gh -p ${{ secrets.GITHUB_TOKEN }}" |
| 44 | + |
| 45 | + test: |
| 46 | + runs-on: ubuntu-latest |
| 47 | + steps: |
| 48 | + - |
| 49 | + uses: actions/checkout@v4 |
| 50 | + - |
| 51 | + name: Set up Helm |
| 52 | + uses: azure/setup-helm@v4 |
| 53 | + with: |
| 54 | + version: ${{ env.HELM_VERSION }} |
| 55 | + - |
| 56 | + name: Install tools |
| 57 | + run: | |
| 58 | + make install-grpcurl |
| 59 | + echo "GRPCURL=$(realpath .ext/bin/grpcurl)" >> "$GITHUB_ENV" |
| 60 | + - |
| 61 | + name: Create Temp Directory |
| 62 | + run: | |
| 63 | + echo "TMPDIR=$(mktemp -d)" >> "$GITHUB_ENV" |
| 64 | + - |
| 65 | + name: Install topaz CLI |
| 66 | + run: | |
| 67 | + gh release download v${{env.TOPAZ_VERSION}} --repo aserto-dev/topaz --pattern "topaz_linux_x86_64.zip" \ |
| 68 | + --output ./ext/topaz.zip --clobber |
| 69 | + unzip ./ext/topaz.zip -d bin |
| 70 | + chmod +x ./bin/topaz |
| 71 | + ./bin/topaz version |
| 72 | + echo "TOPAZ=$(realpath ./bin/topaz)" >> "$GITHUB_ENV" |
| 73 | + echo "TOPAZ_CERTS_DIR=$(./bin/topaz config info | jq '.config.topaz_certs_dir' -r)" >> "$GITHUB_ENV" |
| 74 | + - |
| 75 | + name: Install topazd container |
| 76 | + run: | |
| 77 | + ${TOPAZ} install --container-tag=${{ env.TOPAZ_VERSION }} |
| 78 | + ${TOPAZ} version |
| 79 | + - |
| 80 | + name: Generate topaz certs |
| 81 | + run: ${TOPAZ} certs generate |
| 82 | + - |
| 83 | + name: Install uv package manager |
| 84 | + uses: astral-sh/setup-uv@v3 |
| 85 | + with: |
| 86 | + version: ${{ env.UV_VERSION }} |
| 87 | + - |
| 88 | + uses: AbsaOSS/k3d-action@v2 |
| 89 | + name: Create k8s cluster |
| 90 | + with: |
| 91 | + cluster-name: "test" |
| 92 | + args: > |
| 93 | + --agents 1 |
| 94 | + --k3s-arg "--disable=metrics-server@server:* -p '8008:80@loadbalancer'" |
| 95 | + - |
| 96 | + name: Configure DNS |
| 97 | + run: | |
| 98 | + sudo tee -a /etc/hosts >/dev/null <<EOF |
| 99 | + # Local self-host cluster |
| 100 | + 127.0.0.1 controller.local.test |
| 101 | + 127.0.0.1 grpc-controller.local.test |
| 102 | + 127.0.0.1 directory.local.test |
| 103 | + 127.0.0.1 grpc-directory.local.test |
| 104 | + 127.0.0.1 discovery.local.test |
| 105 | + EOF |
| 106 | + - |
| 107 | + name: Test Topaz |
| 108 | + timeout-minutes: 10 |
| 109 | + env: |
| 110 | + TOPAZ_CERTS_DIR: ${{ env.TOPAZ_CERTS_DIR }} |
| 111 | + run: | |
| 112 | + make test-topaz |
| 113 | + - |
| 114 | + name: Test Discovery |
| 115 | + timeout-minutes: 10 |
| 116 | + env: |
| 117 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 118 | + run: | |
| 119 | + make test-discovery |
| 120 | + - |
| 121 | + name: Deploy Postgres |
| 122 | + run: | |
| 123 | + helm install postgresql oci://registry-1.docker.io/bitnamicharts/postgresql \ |
| 124 | + --namespace postgres --create-namespace \ |
| 125 | + --set auth.postgresPassword=${{ env.POSTGRES_PASSWORD }} |
| 126 | + - |
| 127 | + name: Wait for Postgres |
| 128 | + run: | |
| 129 | + echo "Waiting for postgres to be ready" |
| 130 | + kubectl wait pods --selector app.kubernetes.io/name=postgresql \ |
| 131 | + --for condition=Ready --namespace postgres --timeout=60s |
| 132 | + - |
| 133 | + name: Generate admin ssh key |
| 134 | + id: sshkey |
| 135 | + run: | |
| 136 | + ssh-keygen -t ed25519 -N "" -f ${HOME}/.ssh/admin_ed25519 |
| 137 | + echo "public_key=${HOME}/.ssh/admin_ed25519.pub" >> "$GITHUB_OUTPUT" |
| 138 | + echo "private_key=${HOME}/.ssh/admin_ed25519" >> "$GITHUB_OUTPUT" |
| 139 | + |
| 140 | + cat << EOF > ${HOME}/.ssh/config |
| 141 | + Host localhost |
| 142 | + StrictHostKeyChecking no |
| 143 | + EOF |
| 144 | + |
| 145 | + chmod 400 ~/.ssh/config |
| 146 | + - |
| 147 | + name: Test Controller |
| 148 | + timeout-minutes: 10 |
| 149 | + env: |
| 150 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 151 | + SSH_PUBLIC_KEY: ${{ steps.sshkey.outputs.public_key }} |
| 152 | + SSH_PRIVATE_KEY: ${{ steps.sshkey.outputs.private_key }} |
| 153 | + TOPAZ_CERTS_DIR: ${{ env.TOPAZ_CERTS_DIR }} |
| 154 | + run: | |
| 155 | + make test-controller |
| 156 | + - |
| 157 | + name: Test Directory |
| 158 | + timeout-minutes: 10 |
| 159 | + env: |
| 160 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 161 | + SSH_PUBLIC_KEY: ${{ steps.sshkey.outputs.public_key }} |
| 162 | + SSH_PRIVATE_KEY: ${{ steps.sshkey.outputs.private_key }} |
| 163 | + TOPAZ_CERTS_DIR: ${{ env.TOPAZ_CERTS_DIR }} |
| 164 | + run: | |
| 165 | + make test-directory |
0 commit comments