diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index af576d04..bc691d93 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -1,8 +1,129 @@ name: pull_request -on: [pull_request] +on: [pull_request, workflow_dispatch] jobs: - pull_request: - uses: MapColonies/shared-workflows/.github/workflows/pull_request.yaml@master - secrets: inherit + eslint: + name: Run eslint + runs-on: ubuntu-latest + + steps: + - name: Check out Git repository + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v1 + with: + node-version: 12 + + - name: Install dependencies + run: npm ci + + - name: Run linters + uses: wearerequired/lint-action@v1 + with: + github_token: ${{ secrets.github_token }} + # Enable linters + eslint: true + prettier: true + eslint_extensions: ts + + - name: OpenAPI Lint Checks + uses: nwestfall/openapi-action@v1.0.2 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + file: ./openapi3.yaml + + tests: + name: Run Tests + runs-on: ubuntu-latest + container: node:16 + + services: + # Label used to access the service container + elasticsearch: + # Docker Hub image + image: elasticsearch:8.13.0 + env: + discovery.type: single-node + xpack.security.enabled: false + xpack.security.enrollment.enabled: false + ES_JAVA_OPTS: "-Xms512m -Xmx512m" + ports: + - 9200:9200 + # Set health checks to wait until elastic has started + options: >- + --health-cmd "curl -f http://localhost:9200/_cluster/health || exit 1" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + minio: + # Docker Hub image + image: quay.io/minio/minio:RELEASE.2024-05-28T17-19-04Z + env: + MINIO_ROOT_USER: minio + MINIO_ROOT_PASSWORD: minio + ports: + - 9000:9000 + # Set health checks to wait until elastic has started + options: >- + --health-cmd "curl -f http://localhost:9000/minio/health/live || exit 1" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + strategy: + matrix: + node: [14.x, 16.x] + + steps: + - name: Check out Git repository + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node }} + + - name: Install Node.js dependencies + run: npm ci + + - name: Wait for Elasticsearch + run: | + until curl -s http://elasticsearch:9200/_cluster/health | grep '"status":"green"'; do + echo "Waiting for Elasticsearch..."; + sleep 5; + done + + - name: Run tests + run: npm run test + + - uses: actions/upload-artifact@v2 + with: + name: Test Reporters + path: reports/** + + security: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Run Snyk to check for vulnerabilities + uses: snyk/actions/node@master + continue-on-error: true + env: + SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} + + build_image: + name: Build Image + runs-on: ubuntu-latest + + steps: + - name: Check out Git repository + uses: actions/checkout@v2 + + - name: build Docker image + run: docker build -t test-build:latest . + + - name: build migrations Docker image + run: docker build -f ./migrations.Dockerfile -t test-migrations-build:latest .