|
| 1 | +name: Continuous Integration |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [master] |
| 6 | + pull_request: |
| 7 | + branches: [master] |
| 8 | + |
| 9 | +permissions: {} |
| 10 | + |
| 11 | +jobs: |
| 12 | + test: |
| 13 | + name: Test |
| 14 | + timeout-minutes: 30 |
| 15 | + strategy: |
| 16 | + matrix: |
| 17 | + os: [ubuntu-latest] |
| 18 | + node-version: [20, 22, 24] |
| 19 | + fail-fast: false |
| 20 | + runs-on: ${{ matrix.os }} |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Set up Docker |
| 25 | + uses: docker/setup-buildx-action@v3 |
| 26 | + |
| 27 | + - name: Start DB2 container |
| 28 | + run: | |
| 29 | + docker run -itd --name db2 \ |
| 30 | + --privileged=true \ |
| 31 | + -e LICENSE=accept \ |
| 32 | + -e DB2INST1_PASSWORD=password \ |
| 33 | + -e DBNAME=testdb \ |
| 34 | + -p 60000:50000 \ |
| 35 | + -v db2data:/db2data \ |
| 36 | + ibmcom/db2 |
| 37 | +
|
| 38 | + - name: Wait for DB2 instance to be up |
| 39 | + run: | |
| 40 | + echo "Waiting for DB2 engine to be ready..." |
| 41 | + for i in {1..20}; do |
| 42 | + docker exec db2 su - db2inst1 -c "db2 connect to sample" >/dev/null 2>&1 && break |
| 43 | + echo "Still waiting ($i)..." |
| 44 | + sleep 5 |
| 45 | + done |
| 46 | +
|
| 47 | + - name: Wait for testdb to be accessible |
| 48 | + run: | |
| 49 | + echo "Waiting for testdb..." |
| 50 | + for i in {1..20}; do |
| 51 | + docker exec db2 su - db2inst1 -c "db2 connect to testdb" >/dev/null 2>&1 && break |
| 52 | + echo "Still waiting ($i)..." |
| 53 | + sleep 5 |
| 54 | + done |
| 55 | +
|
| 56 | + - name: Use Node.js ${{ matrix.node-version }} |
| 57 | + uses: actions/setup-node@v4 |
| 58 | + with: |
| 59 | + node-version: ${{ matrix.node-version }} |
| 60 | + |
| 61 | + - run: npm ci |
| 62 | + |
| 63 | + - name: Run test |
| 64 | + run: npm test --ignore-scripts |
| 65 | + |
| 66 | + - name: Dump DB2 logs on failure |
| 67 | + if: failure() |
| 68 | + run: docker logs db2 |
| 69 | + |
| 70 | + - name: Cleanup DB2 container |
| 71 | + if: always() |
| 72 | + run: docker rm -f db2 |
| 73 | + |
| 74 | + code-lint: |
| 75 | + name: Code Lint |
| 76 | + runs-on: ubuntu-latest |
| 77 | + steps: |
| 78 | + - uses: actions/checkout@v4 |
| 79 | + - uses: actions/setup-node@v4 |
| 80 | + with: |
| 81 | + node-version: 22 |
| 82 | + - run: npm ci --ignore-scripts |
| 83 | + - name: Verify code linting |
| 84 | + run: npx --no eslint . |
| 85 | + |
| 86 | + commit-lint: |
| 87 | + name: Commit Lint |
| 88 | + runs-on: ubuntu-latest |
| 89 | + if: ${{ github.event.pull_request }} |
| 90 | + steps: |
| 91 | + - uses: actions/checkout@v4 |
| 92 | + with: |
| 93 | + fetch-depth: 0 |
| 94 | + - uses: actions/setup-node@v4 |
| 95 | + with: |
| 96 | + node-version: 22 |
| 97 | + - run: npm ci |
| 98 | + - name: Verify commit linting |
| 99 | + run: npx commitlint --from origin/master --to HEAD --verbose |
0 commit comments