Skip to content

Commit

Permalink
test CI more refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
tsubik committed Mar 6, 2024
1 parent 5813f7f commit ba91110
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 20 deletions.
60 changes: 41 additions & 19 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ env:
POSTGRES_PASSWORD: postgres
POSTGRES_PORT_5432_TCP_ADDR: localhost
POSTGRES_PORT_5432_TCP_PORT: 5432
APP_URL: http://localhost:3000
RAILS_ENV: e2e
SECRET_KEY_BASE: f54c9d76c42e397e17cbc0d0a024da5a762a7a0d934839b417a77dac6fda65a49a37b32bcd229ac5fd5c1fedef8ed6acf7a57ed6465d6339862cdc0dfab8886f
AUTH_SECRET: secret
Expand Down Expand Up @@ -32,14 +31,21 @@ jobs:
ports: ["5432:5432"]

steps:
- uses: actions/checkout@v4
- name: Checkout Portal
uses: actions/checkout@v4

- uses: actions/checkout@v4
- name: Checkout OTP API
uses: actions/checkout@v4
with:
repository: wri/fti_api
ref: chore/upgrade-rails
path: otp_api

- name: Save OTP API Commit SHA
id: otp_api_commit_sha
working-directory: otp_api
run: echo "VALUE=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT

- name: Install API dependencies
run: |
sudo apt update --fix-missing
Expand All @@ -52,10 +58,25 @@ jobs:
bundler-cache: true
working-directory: otp_api

- name: Restore API Precompiled Assets Cache
id: cache-api-precompiled-assets
uses: actions/cache/restore@v3
with:
path: otp_api/public/assets
key: api-precompiled-assets-${{ steps.otp_api_commit_sha.outputs.VALUE }}

- name: Setup API
working-directory: otp_api
env:
APP_URL: http://localhost:3000
run: |
bin/rails e2e:setup
bin/rails e2e:setup ${{ steps.cache-api-precompiled-assets.outputs.cache-hit == 'true' && 'SKIP_ASSETS_RESET=true' || '' }}
- name: Save API Precompiled Assets Cache
uses: actions/cache/save@v3
with:
path: otp_api/public/assets
key: api-precompiled-assets-${{ steps.otp_api_commit_sha.outputs.VALUE }}

- name: Read API Access Token
id: api_key
Expand All @@ -65,6 +86,8 @@ jobs:
- name: Run API Server
working-directory: otp_api
env:
APP_URL: http://localhost:3000
run: |
bin/rails s &
Expand Down Expand Up @@ -113,7 +136,6 @@ jobs:
echo "
PORT=4000
NODE_ENV=production
ENV=production
SECRET=session_secret
OTP_COUNTRIES='COG,CMR,COD,CAF,GAB'
OTP_COUNTRIES_IDS='7,47,45,188,53'
Expand All @@ -123,35 +145,35 @@ jobs:
DISABLE_HOTJAR=true
" > .env
# - name: Cache Next.js Build
# id: cache-nextjs
# uses: actions/cache/restore@v3
# with:
# path: |
# ${{ github.workspace }}/.next/cache
# # Generate a new cache whenever packages or source files change.
# key: ${{ runner.os }}-nextjs-${{ hashFiles('yarn.lock') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
- name: Restore Next.js Build Cache
id: cache-nextjs
uses: actions/cache/restore@v3
with:
path: .next/cache
key: nextjs-${{ hashFiles('yarn.lock') }}

- name: Build Portal
run: yarn build

# - uses: actions/cache/save@v3
# with:
# path: .next/cache
# key: ${{ runner.os }}-nextjs-${{ hashFiles('yarn.lock') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
- name: Save Next.js Build Cache
uses: actions/cache/save@v3
with:
path: .next/cache
key: nextjs-${{ hashFiles('yarn.lock') }}

- name: Start Portal
run: yarn start &

- name: Run E2E Tests
working-directory: e2e
run: yarn cypress run
# run: yarn cypress run
run: yarn cypress run --spec cypress/e2e/pages.cy.js,cypress/e2e/user.cy.js

- name: Uploading Test Artifacts
uses: actions/upload-artifact@v2
if: failure()
with:
name: cypress-screenshots
name: e2e-tests-artifacts
path: |
e2e/cypress/screenshots
e2e/cypress/videos
Expand Down
3 changes: 3 additions & 0 deletions e2e/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ module.exports = defineConfig({
video: false,
viewportWidth: 1280,
viewportHeight: 720,
env: {
pluginVisualRegressionMaxDiffThreshold: 0.03,
},
e2e: {
baseUrl: 'http://localhost:4000',
// We've imported your old cypress plugins here.
Expand Down
2 changes: 1 addition & 1 deletion e2e/cypress/e2e/user.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('User', () => {
})

context('Login form', () => {
it('can log in', function () {
it.only('can log in', function () {
cy.visit('/');
cy.get('a').contains('Sign in').click();
cy.get('#input-email').type('[email protected]');
Expand Down

0 comments on commit ba91110

Please sign in to comment.