|
| 1 | +name: PR Tests |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [ labeled ] |
| 6 | + branches: |
| 7 | + - main |
| 8 | + paths: |
| 9 | + - 'frontend/**' |
| 10 | + - 'backend/**' |
| 11 | + workflow_dispatch: |
| 12 | + |
| 13 | +permissions: |
| 14 | + contents: read |
| 15 | + |
| 16 | +jobs: |
| 17 | + pr-tests: |
| 18 | + name: PR Tests |
| 19 | + runs-on: ubuntu-22.04 |
| 20 | + steps: |
| 21 | + - name: Checkout repository |
| 22 | + uses: actions/checkout@v4 |
| 23 | + with: |
| 24 | + fetch-depth: 0 |
| 25 | + |
| 26 | + - name: Setup Node |
| 27 | + uses: actions/setup-node@v4 |
| 28 | + with: |
| 29 | + node-version: 22 |
| 30 | + cache-dependency-path: ./frontend/package-lock.json |
| 31 | + |
| 32 | + - name: Install frontend dependencies |
| 33 | + run: npm ci |
| 34 | + working-directory: ./frontend |
| 35 | + |
| 36 | + - name: Build frontend |
| 37 | + run: npm run build |
| 38 | + working-directory: ./frontend |
| 39 | + |
| 40 | + - uses: nick-fields/retry@v3 |
| 41 | + with: |
| 42 | + timeout_minutes: 5 |
| 43 | + max_attempts: 3 |
| 44 | + retry_on: error |
| 45 | + command: npm run --prefix ./frontend test |
| 46 | + |
| 47 | + - name: Copy frontend build to backend |
| 48 | + run: | |
| 49 | + mkdir -p static |
| 50 | + cp -r ../frontend/dist/* ./static |
| 51 | + working-directory: ./backend |
| 52 | + |
| 53 | + # https://github.com/twistedfall/opencv-rust/blob/master/ci/install-ubuntu.sh#L27 |
| 54 | + - name: Use clang workaround |
| 55 | + run: sudo ln -fs libclang.so.1 /usr/lib/llvm-14/lib/libclang.so |
| 56 | + |
| 57 | + - name: Restore Apt packages |
| 58 | + uses: awalsh128/cache-apt-pkgs-action@v1 |
| 59 | + with: |
| 60 | + packages: libopencv-dev |
| 61 | + version: "1.0" |
| 62 | + |
| 63 | + - name: Install Rust toolchain |
| 64 | + uses: dtolnay/rust-toolchain@1.81.0 |
| 65 | + |
| 66 | + - name: Restore Rust cache |
| 67 | + uses: Swatinem/rust-cache@v2 |
| 68 | + with: |
| 69 | + workspaces: ./backend |
| 70 | + |
| 71 | + - name: Build backend |
| 72 | + run: cargo build |
| 73 | + working-directory: ./backend |
| 74 | + |
| 75 | + - name: Run backend tests |
| 76 | + uses: nick-fields/retry@v3 |
| 77 | + with: |
| 78 | + timeout_minutes: 5 |
| 79 | + max_attempts: 3 |
| 80 | + retry_on: error |
| 81 | + command: cd ${GITHUB_WORKSPACE}/backend && cargo test |
0 commit comments