chore: spring cleaning #38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| jobs: | |
| check-commits: | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'pull_request' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| # Fetch all history | |
| fetch-depth: 0 | |
| - name: Check commit messages | |
| run: | | |
| scripts/check-commits.sh ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | |
| shellcheck: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Shellcheck | |
| run: | | |
| shellcheck scripts/*.sh | |
| lint: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| node: [24] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Node ${{ matrix.node }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node }} | |
| # https://github.com/actions/cache/blob/v2.1.5/examples.md#node---yarn-2 | |
| - uses: actions/cache@v4 | |
| with: | |
| path: .yarn/cache | |
| key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-yarn- | |
| - name: Check yarn lockfile | |
| run: | | |
| yarn dedupe -c | |
| - name: Install dependencies | |
| run: | | |
| yarn install --immutable | |
| - name: Run codegen | |
| run: | | |
| yarn workspace @rctf/api-types build | |
| - name: Prettier | |
| run: | | |
| yarn prettier -c . | |
| - name: Lint | |
| run: | | |
| yarn lint --max-warnings=0 | |
| - name: Typecheck | |
| run: | | |
| yarn typecheck | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| node: [24] | |
| postgres: [12] | |
| redis: [6] | |
| services: | |
| postgres: | |
| image: postgres:${{ matrix.postgres }} | |
| env: | |
| POSTGRES_PASSWORD: password | |
| ports: | |
| - 5432:5432 | |
| redis: | |
| image: redis:${{ matrix.redis }} | |
| ports: | |
| - 6379:6379 | |
| env: | |
| RCTF_DATABASE_URL: postgres://postgres:password@localhost/rctf | |
| RCTF_REDIS_URL: redis://@localhost:6379/0 | |
| RCTF_TOKEN_KEY: 32_byte_long_base64_encoded_value_for_token | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Node ${{ matrix.node }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node }} | |
| # https://github.com/actions/cache/blob/v4.2.3/examples.md#node---yarn-2 | |
| - uses: actions/cache@v4 | |
| with: | |
| path: .yarn/cache | |
| key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-yarn- | |
| - name: Install dependencies | |
| run: | | |
| yarn install --immutable | |
| - name: Build | |
| run: | | |
| yarn build | |
| - name: Create DB | |
| run: | | |
| psql postgres://postgres:password@localhost -c 'CREATE DATABASE rctf;' | |
| - name: Run migrations | |
| run: | | |
| yarn workspace @rctf/server migrate | |
| - name: Run tests | |
| id: testrun | |
| run: | | |
| yarn test:report --ci --forceExit --color | |
| - name: Upload coverage reports | |
| if: always() && ((steps.testrun.outcome == 'success') || (steps.testrun.outcome == 'failure')) | |
| uses: codecov/codecov-action@v1 | |
| docker-build: | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'otter-sec/rctf' | |
| needs: | |
| - shellcheck | |
| - lint | |
| - test | |
| permissions: | |
| packages: write | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v4 | |
| # https://github.com/actions/cache/blob/v4.2.3/examples.md#node---yarn-2 | |
| - uses: actions/cache@v4 | |
| with: | |
| path: .yarn/cache | |
| key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-yarn- | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to registry | |
| run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
| - name: Build | |
| uses: docker/build-push-action@v6 | |
| with: | |
| push: ${{ github.ref == 'refs/heads/main' }} | |
| tags: | | |
| ghcr.io/otter-sec/rctf:${{ github.sha }} | |
| ghcr.io/otter-sec/rctf:${{ github.ref_name }} | |
| cache-from: type=registry,ref=ghcr.io/otter-sec/rctf:main | |
| cache-to: type=inline |