Test app inside container #258
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
| # This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node | |
| # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | |
| name: Node.js CI | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| node-version: [24.x] | |
| # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Use Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: 'npm' | |
| - run: npm ci | |
| - run: npm run lint:ci | |
| - name: Create local config for the app to connect to couchdb service in the container | |
| run: | | |
| echo 'module.exports = { usersDbConnection: { url: "http://couchdb:5984" }};' > config/local.js | |
| - name: Start docker compose services | |
| run: docker compose up -d && sleep 5 | |
| - name: Show docker compose logs | |
| run: docker compose logs --no-color --timestamps || true | |
| - name: Run setup | |
| run: npm run setup | |
| env: | |
| SOURCE_URL: ${{ secrets.SOURCE_URL }} | |
| DEBUG: 'none' | |
| - name: Run E2E tests against the container app | |
| run: npm run test:deprecated:e2e || echo 'Test run failed when trying to use the deployed auth app' | |
| env: | |
| SOURCE_URL: ${{ secrets.SOURCE_URL }} | |
| DEBUG: 'none' | |
| - name: Show docker compose logs | |
| if: success() || failure() | |
| run: docker compose logs --no-color --timestamps || true | |
| integration-tests: | |
| runs-on: ubuntu-latest | |
| needs: [deploy] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Use Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: 'npm' | |
| - name: Create local config for tests to use the couchdb from the container | |
| run: | | |
| echo 'module.exports = { usersDbConnection: { url: "http://localhost:5984" }};' > config/local.js | |
| - name: Run Integration tests | |
| run: DEBUG=replay* npm run coverage || echo 'Test run failed replay no longer is working with latest nano which uses node fetch' | |
| - name: Run integration tests using the app with local couchdb | |
| run: npm run test:deprecated:coverage | |
| env: | |
| SOURCE_URL: ${{ secrets.SOURCE_URL }} | |
| DEBUG: 'none' | |
| - name: Upload coverage report | |
| uses: actions/upload-artifact@v5 | |
| if: success() || failure() | |
| with: | |
| name: coverage | |
| path: coverage/ | |
| retention-days: 3 | |
| - name: Coveralls | |
| if: success() || failure() | |
| uses: coverallsapp/github-action@master | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| ui-tests: | |
| runs-on: ubuntu-latest | |
| needs: [deploy] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| sparse-checkout: | | |
| package.json | |
| - name: Use Node.js 24.x | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24.x | |
| cache: 'npm' | |
| - name: Run UI tests | |
| run: npm run test:ui | |
| timeout-minutes: 5 | |
| env: | |
| BASE_URL: https://localhost:6984 | |
| BASE_PATH: /prototypedev/_design/prototype | |
| - name: Upload Playwright report and traces for trace.playwright.dev | |
| uses: actions/upload-artifact@v5 | |
| if: ${{ !cancelled() }} # Upload even if the previous step failed | |
| with: | |
| name: test-results # Name of the artifact | |
| path: FieldDB/test-e2e/test-results/ # Path to the directory containing reports and traces | |
| retention-days: 30 |