Skip to content

Commit

Permalink
fix: E2E tests on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Betree committed Jan 8, 2023
1 parent 65860ee commit 0f9f602
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 28 deletions.
56 changes: 35 additions & 21 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,46 +18,60 @@ jobs:
--health-timeout 5s
--health-retries 5
steps:
# Checkout
- name: Checkout API
uses: actions/checkout@v1
uses: actions/checkout@v3
with:
repository: CaptainFact/captain-fact-api
path: api
- name: Checkout Frontend
uses: actions/checkout@v2
with:
repository: CaptainFact/captain-fact-frontend
ref: refs/heads/staging
path: frontend
# Setup API
- name: Restore Elixir cache
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
path: ./api/deps
key: ${{ runner.os }}-mix-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-${{ env.cache-name }}-
${{ runner.os }}-mix-
- name: Restore Elixir build folder
uses: actions/cache@v1
with:
path: build
key: ${{ runner.os }}-mix-build
path: ./api/build
key: ${{ runner.os }}-mix-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-${{ env.cache-name }}-
${{ runner.os }}-mix-
- uses: erlef/setup-beam@v1
with:
version-file: .tool-versions
version-file: ./api/.tool-versions
version-type: strict
- name: Install API's dependencies
working-directory: api
run: mix deps.get
- name: Compile dependencies
working-directory: api
run: mix deps.compile
- name: Compile project
working-directory: api
run: mix compile
- name: Prepare DB
working-directory: api
run: mix ecto.create && mix ecto.migrate
- uses: actions/setup-node@v1
- name: Checkout Frontend
uses: actions/checkout@v2
with:
repository: CaptainFact/captain-fact-frontend
ref: refs/heads/staging
path: ./captain-fact-frontend
- name: Restore node_modules
uses: actions/cache@v1
id: node-modules
# Setup Frontend
- uses: actions/setup-node@v3
with:
path: captain-fact-frontend/node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('captain-fact-frontend/package-lock.json') }}
node-version-file: "../../frontend/.tool-versions"
cache: "npm"
- name: Install Frontend's dependencies
working-directory: captain-fact-frontend
working-directory: /home/runner/work/frontend
run: npm ci --prefer-offline --no-audit
- run: ./scripts/run_e2e_ci.sh
# Run tests
- name: Start E2E tests
working-directory: /home/runner/work/api
run: ./scripts/run_e2e_ci.sh
11 changes: 4 additions & 7 deletions scripts/run_e2e_ci.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#!/usr/bin/env bash

cd "$(dirname "$(realpath "$0")")"/..

# Start API
cd ./api
iex -S mix run &

# Start Frontend
cd captain-fact-frontend
cd ../frontend
npm run dev &

# Waiting for API to be ready
Expand All @@ -15,9 +18,3 @@ timeout 1m bash -c "until curl localhost:3333 > /dev/null; do sleep 1; done"

# Run tests
npm run cypress
RETURN_CODE=$?

# Shutdown everything
kill $(jobs -p) || true

exit $RETURN_CODE

0 comments on commit 0f9f602

Please sign in to comment.