Test app inside container #262
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: [25.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/localhost.js | |
| - name: Start docker compose services | |
| run: docker compose up -d && sleep 5 | |
| - name: Show docker compose logs after creating services | |
| run: docker compose logs --no-color --timestamps || true | |
| - name: Run setup databases in the couchdb inside the container | |
| run: npm run setup | |
| env: | |
| SOURCE_URL: ${{ secrets.SOURCE_URL }} | |
| DEBUG: 'none' | |
| - name: Run E2E tests against the container app | |
| run: DEBUG=test:deprecated npm run test:deprecated:e2e | |
| env: | |
| SOURCE_URL: ${{ secrets.SOURCE_URL }} | |
| DEBUG: 'none' | |
| - name: Show docker compose logs after running tests | |
| if: success() || failure() | |
| run: docker compose logs --no-color --timestamps | grep -v "couchdb" || true | |
| - name: Create local config for tests to use the couchdb outside the container | |
| run: | | |
| echo 'module.exports = { usersDbConnection: { url: "http://localhost:5984" }};' > config/localhost.js | |
| - name: Run integration tests using the app against the couchdb in the contianer | |
| run: npm run test:deprecated:coverage | |
| env: | |
| SOURCE_URL: ${{ secrets.SOURCE_URL }} | |
| DEBUG: 'test:deprecated' | |
| - 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 }} | |
| 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' | |
| - run: npm ci | |
| - 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' | |
| ui-tests: | |
| runs-on: ubuntu-latest | |
| needs: [deploy] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| sparse-checkout: | | |
| package.json | |
| - name: Use Node.js 25.x | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 25.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: ui-test-results # Name of the artifact | |
| path: FieldDB/test-e2e/test-results/ # Path to the directory containing reports and traces | |
| retention-days: 30 |