|
| 1 | +name: Build and Test |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + |
| 6 | +jobs: |
| 7 | + build: |
| 8 | + name: build:required |
| 9 | + runs-on: ubuntu-latest |
| 10 | + steps: |
| 11 | + - name: Checkout |
| 12 | + uses: actions/checkout@v4 |
| 13 | + |
| 14 | + - name: Setup PNPM |
| 15 | + uses: dfinity/ci-tools/actions/setup-pnpm@main |
| 16 | + with: |
| 17 | + node_version_file: '.nvmrc' |
| 18 | + |
| 19 | + - name: Build |
| 20 | + run: pnpm build |
| 21 | + |
| 22 | + - name: Upload Build Artifacts |
| 23 | + uses: actions/upload-artifact@v4 |
| 24 | + with: |
| 25 | + name: build-artifact |
| 26 | + path: ./packages/*/lib/ |
| 27 | + |
| 28 | + tests: |
| 29 | + name: tests:required |
| 30 | + runs-on: ubuntu-latest |
| 31 | + needs: build |
| 32 | + strategy: |
| 33 | + fail-fast: false |
| 34 | + matrix: |
| 35 | + test_type: [unit, e2e, mitm] |
| 36 | + node: |
| 37 | + - 20.18 # without require(esm) |
| 38 | + - 20.19 # with require(esm), see https://nodejs.org/en/blog/release/v20.19.0/#requireesm-is-now-enabled-by-default |
| 39 | + - 22 |
| 40 | + steps: |
| 41 | + - name: Checkout code |
| 42 | + uses: actions/checkout@v4 |
| 43 | + |
| 44 | + - name: Setup PNPM |
| 45 | + uses: dfinity/ci-tools/actions/setup-pnpm@main |
| 46 | + with: |
| 47 | + node_version: ${{ matrix.node }} |
| 48 | + |
| 49 | + - name: Download Build Artifacts |
| 50 | + uses: actions/download-artifact@v4 |
| 51 | + with: |
| 52 | + name: build-artifact |
| 53 | + path: ./ |
| 54 | + |
| 55 | + - name: Setup DFX |
| 56 | + if: ${{ matrix.test_type == 'mitm' || matrix.test_type == 'e2e' }} |
| 57 | + uses: dfinity/setup-dfx@main |
| 58 | + |
| 59 | + - name: Setup e2e tests |
| 60 | + if: ${{ matrix.test_type == 'e2e' }} |
| 61 | + run: pnpm run -F @e2e/node setup |
| 62 | + |
| 63 | + - name: Setup mitm tests |
| 64 | + if: ${{ matrix.test_type == 'mitm' }} |
| 65 | + working-directory: e2e/node |
| 66 | + run: | |
| 67 | + dfx start --background |
| 68 | + dfx deploy counter |
| 69 | +
|
| 70 | + - name: Running mitmdump |
| 71 | + if: ${{ matrix.test_type == 'mitm' }} |
| 72 | + run: | |
| 73 | + set -ex |
| 74 | + mitmdump -p 8888 --mode reverse:http://localhost:4943 \ |
| 75 | + --modify-headers '/~s/Transfer-Encoding/' \ |
| 76 | + --modify-body '/~s/Hello/Hullo' \ |
| 77 | + & |
| 78 | + sleep 20 |
| 79 | +
|
| 80 | + - name: Run unit tests |
| 81 | + if: ${{ matrix.test_type == 'unit' }} |
| 82 | + run: pnpm test |
| 83 | + |
| 84 | + - name: Run e2e tests |
| 85 | + if: ${{ matrix.test_type == 'e2e' }} |
| 86 | + run: pnpm run -F @e2e/node e2e |
| 87 | + |
| 88 | + - name: Run mitm tests |
| 89 | + if: ${{ matrix.test_type == 'mitm' }} |
| 90 | + run: pnpm run -F @e2e/node mitm |
| 91 | + |
| 92 | + - name: Run Tests |
| 93 | + run: | |
| 94 | + if [ "${{ matrix.test_type }}" == "unit" ]; then |
| 95 | + pnpm test; |
| 96 | + elif [ "${{ matrix.test_type }}" == "e2e" ]; then |
| 97 | + pnpm run -F @e2e/node e2e; |
| 98 | + else |
| 99 | + pnpm run -F @e2e/node mitm; |
| 100 | + fi |
| 101 | +
|
| 102 | + build_docs: |
| 103 | + name: build_docs:required |
| 104 | + runs-on: ubuntu-latest |
| 105 | + needs: build |
| 106 | + steps: |
| 107 | + - name: Checkout code |
| 108 | + uses: actions/checkout@v4 |
| 109 | + |
| 110 | + - name: Setup PNPM |
| 111 | + uses: dfinity/ci-tools/actions/setup-pnpm@main |
| 112 | + with: |
| 113 | + node_version_file: '.nvmrc' |
| 114 | + |
| 115 | + - name: Download Build Artifacts |
| 116 | + uses: actions/download-artifact@v4 |
| 117 | + with: |
| 118 | + name: build-artifact |
| 119 | + path: ./ |
| 120 | + |
| 121 | + - name: Generate docs |
| 122 | + run: pnpm make:docs |
| 123 | + |
| 124 | + size_limit: |
| 125 | + name: size_limit:required |
| 126 | + runs-on: ubuntu-latest |
| 127 | + needs: build |
| 128 | + steps: |
| 129 | + - name: Checkout code |
| 130 | + uses: actions/checkout@v4 |
| 131 | + |
| 132 | + - name: Setup PNPM |
| 133 | + uses: dfinity/ci-tools/actions/setup-pnpm@main |
| 134 | + with: |
| 135 | + node_version_file: '.nvmrc' |
| 136 | + |
| 137 | + - name: Download Build Artifacts |
| 138 | + uses: actions/download-artifact@v4 |
| 139 | + with: |
| 140 | + name: build-artifact |
| 141 | + path: ./ |
| 142 | + |
| 143 | + - uses: andresz1/size-limit-action@v1 |
| 144 | + with: |
| 145 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 146 | + build_script: bundle |
| 147 | + |
| 148 | + audit: |
| 149 | + name: audit:required |
| 150 | + runs-on: ubuntu-latest |
| 151 | + needs: build |
| 152 | + steps: |
| 153 | + - name: Checkout code |
| 154 | + uses: actions/checkout@v4 |
| 155 | + |
| 156 | + - name: Setup PNPM |
| 157 | + uses: dfinity/ci-tools/actions/setup-pnpm@main |
| 158 | + with: |
| 159 | + node_version_file: '.nvmrc' |
| 160 | + |
| 161 | + - name: Run audit |
| 162 | + run: pnpm audit |
| 163 | + |
| 164 | + attw: |
| 165 | + name: attw:required |
| 166 | + runs-on: ubuntu-latest |
| 167 | + needs: build |
| 168 | + steps: |
| 169 | + - name: Checkout code |
| 170 | + uses: actions/checkout@v4 |
| 171 | + |
| 172 | + - name: Setup PNPM |
| 173 | + uses: dfinity/ci-tools/actions/setup-pnpm@main |
| 174 | + with: |
| 175 | + node_version_file: '.nvmrc' |
| 176 | + |
| 177 | + - name: Download Build Artifacts |
| 178 | + uses: actions/download-artifact@v4 |
| 179 | + with: |
| 180 | + name: build-artifact |
| 181 | + path: ./ |
| 182 | + |
| 183 | + - name: Run attw |
| 184 | + run: pnpm attw |
| 185 | + |
| 186 | + format_check: |
| 187 | + name: format_check:required |
| 188 | + runs-on: ubuntu-latest |
| 189 | + steps: |
| 190 | + - name: Checkout code |
| 191 | + uses: actions/checkout@v4 |
| 192 | + |
| 193 | + - name: Setup PNPM |
| 194 | + uses: dfinity/ci-tools/actions/setup-pnpm@main |
| 195 | + with: |
| 196 | + node_version_file: '.nvmrc' |
| 197 | + |
| 198 | + - name: Check formatting |
| 199 | + run: pnpm prettier:check |
| 200 | + |
| 201 | + lint: |
| 202 | + name: lint:required |
| 203 | + runs-on: ubuntu-latest |
| 204 | + steps: |
| 205 | + - name: Checkout code |
| 206 | + uses: actions/checkout@v4 |
| 207 | + |
| 208 | + - name: Setup PNPM |
| 209 | + uses: dfinity/ci-tools/actions/setup-pnpm@main |
| 210 | + with: |
| 211 | + node_version_file: '.nvmrc' |
| 212 | + |
| 213 | + - name: Run Lint |
| 214 | + run: pnpm lint |
| 215 | + |
0 commit comments