diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 41b3658a..1fbf3ced 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -18,46 +18,61 @@ 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-dependency-path: "./frontend/package-lock.json" + cache: "npm" - name: Install Frontend's dependencies - working-directory: captain-fact-frontend + working-directory: frontend run: npm ci --prefer-offline --no-audit - - run: ./scripts/run_e2e_ci.sh + # Run tests + - name: Start E2E tests + working-directory: api + run: ./scripts/run_e2e_ci.sh diff --git a/scripts/run_e2e_ci.sh b/scripts/run_e2e_ci.sh index 75a593fa..53db9dea 100755 --- a/scripts/run_e2e_ci.sh +++ b/scripts/run_e2e_ci.sh @@ -1,10 +1,13 @@ #!/usr/bin/env bash +cd "$(dirname "$(realpath "$0")")"/.. + # Start API -iex -S mix run & +cd ./api +mix run --no-halt & # Start Frontend -cd captain-fact-frontend +cd ../frontend npm run dev & # Waiting for API to be ready @@ -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 \ No newline at end of file