|
| 1 | +name: E2E Tests |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - main |
| 6 | + - master |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + - master |
| 11 | + |
| 12 | +jobs: |
| 13 | + e2e-tests: |
| 14 | + runs-on: ${{ matrix.os }} |
| 15 | + |
| 16 | + strategy: |
| 17 | + matrix: |
| 18 | + os: [ubuntu-latest] |
| 19 | + python-version: [3.10.5] |
| 20 | + node: [16] |
| 21 | + |
| 22 | + services: |
| 23 | + db: |
| 24 | + image: postgres |
| 25 | + env: |
| 26 | + POSTGRES_USER: postgres |
| 27 | + POSTGRES_PASSWORD: postgres |
| 28 | + POSTGRES_DB: github-actions |
| 29 | + ports: |
| 30 | + - 5432:5432 |
| 31 | + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 |
| 32 | + |
| 33 | + steps: |
| 34 | + - name: Checkout 🛎 |
| 35 | + uses: actions/checkout@v3 |
| 36 | + |
| 37 | + - name: Setup node env 🏗 |
| 38 | + uses: actions/setup-node@v3.4.1 |
| 39 | + with: |
| 40 | + node-version: ${{ matrix.node }} |
| 41 | + check-latest: true |
| 42 | + |
| 43 | + - name: Get yarn cache directory path 🛠 |
| 44 | + id: yarn-cache-dir-path |
| 45 | + run: echo "::set-output name=dir::$(yarn cache dir)" |
| 46 | + working-directory: client |
| 47 | + |
| 48 | + - name: Cache node_modules 📦 |
| 49 | + uses: actions/cache@v3.0.5 |
| 50 | + id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) |
| 51 | + with: |
| 52 | + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} |
| 53 | + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} |
| 54 | + restore-keys: | |
| 55 | + ${{ runner.os }}-yarn- |
| 56 | +
|
| 57 | + - name: Install yarn dependencies 👨🏻💻 |
| 58 | + run: yarn |
| 59 | + working-directory: client |
| 60 | + |
| 61 | + - name: Setup Python env 🏗 |
| 62 | + uses: actions/setup-python@v4 |
| 63 | + with: |
| 64 | + python-version: ${{ matrix.python-version }} |
| 65 | + architecture: x64 |
| 66 | + |
| 67 | + - name: Setup Poetry 🏗 |
| 68 | + uses: snok/install-poetry@v1 |
| 69 | + with: |
| 70 | + version: 1.1.10 |
| 71 | + virtualenvs-create: true |
| 72 | + virtualenvs-in-project: true |
| 73 | + |
| 74 | + - name: Cache .venv 📦 |
| 75 | + id: cached-poetry-dependencies |
| 76 | + uses: actions/cache@v3.0.5 |
| 77 | + with: |
| 78 | + path: server/.venv |
| 79 | + key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} |
| 80 | + |
| 81 | + - name: Install Python dependencies 👨🏻💻 |
| 82 | + run: poetry install |
| 83 | + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' |
| 84 | + working-directory: server |
| 85 | + |
| 86 | + - name: Run Migrations 🕊️ |
| 87 | + run: | |
| 88 | + source .venv/bin/activate |
| 89 | + python manage.py migrate |
| 90 | + working-directory: server |
| 91 | + |
| 92 | + - name: Start backend 🚛 |
| 93 | + run: | |
| 94 | + source .venv/bin/activate |
| 95 | + python manage.py runserver 0.0.0.0:8081 & |
| 96 | + sleep 5 && |
| 97 | + curl http://localhost:8081 -I |
| 98 | + working-directory: server |
| 99 | + |
| 100 | + - name: Run Cypress tests 🧪 |
| 101 | + uses: cypress-io/github-action@v4 |
| 102 | + with: |
| 103 | + working-directory: client |
| 104 | + install-command: yarn --frozen-lockfile --silent |
| 105 | + build: yarn build |
| 106 | + start: yarn start |
0 commit comments