Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getting coverage to work #1053

Merged
merged 24 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ src/.npm
src/_tmp
src/.cache
src/.config
src/.nyc_output
src/dist
**/.next
_data
23 changes: 17 additions & 6 deletions .github/workflows/aps-cypress-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Cypress and Execute Tests
on:
workflow_dispatch: {}
push:
branches: ['test', 'cypress*']
branches: ['test', 'cypress/*']

env:
DASHBOARD_PROJECT_ID: ${{ secrets.CY_DASHBOARD_PRJ_ID }}
Expand Down Expand Up @@ -70,15 +70,26 @@ jobs:
name: code-coverage
path: ${{ github.workspace }}/e2e/coverage

- name: Instrument the code for coverage analysis
run: |
# Rewrite the paths as the coverage starts with '../app'!
sed -e 's/..\/app/./g' ./e2e/coverage/lcov.info > lcov.info

#cd src
#npm install --legacy-peer-deps
#npx nyc instrument --compact=false . --in-place

- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@master
with:
args: >
-Dsonar.organization=bcgov-oss
-Dsonar.projectKey=aps-portal-e2e
-Dsonar.host.url=https://sonarcloud.io
-Dsonar.sources=src/nextapp
-Dsonar.javascript.lcov.reportPaths=./e2e/coverage/lcov.info
-Dsonar.projectBaseDir=src
-Dsonar.sources=.
-Dsonar.exclusions=nextapp/**,mocks/**,test/**,tools/**,*.json,*.js
-Dsonar.javascript.lcov.reportPaths=/github/workspace/lcov.info
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Expand All @@ -96,13 +107,13 @@ jobs:
gh issue create --title "FAILED: Automated Tests($FAILURE_COUNT)" --body "$MSG" --label "automation" --assignee "${{ env.GIT_COMMIT_AUTHOR }}"
exit 1
fi

- name: Set up Python 3.9
if: failure()
uses: actions/setup-python@v2
with:
python-version: "3.9"
architecture: "x64"
python-version: '3.9'
architecture: 'x64'

- name: Install Python dependencies
if: failure()
Expand Down
16 changes: 12 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ services:
container_name: cypress-e2e
entrypoint: sh -c "chmod +x /tmp/entrypoint.sh && /tmp/entrypoint.sh"
environment:
- BROWSER=edge
- CYPRESS_RECORD_KEY=${CY_RECORD_KEY}
- CYPRESS_PROJECT_ID=${CY_PROJECT_ID}
- RUN_ENV=${CY_EXECUTION_ENV}
Expand All @@ -228,24 +229,28 @@ services:
depends_on:
- feeder-seeding
build:
context: ./e2e
dockerfile: Dockerfile
context: .
dockerfile: e2e/Dockerfile
volumes:
- ./e2e/coverage:/e2e/coverage
- ./e2e/results:/e2e/results
networks:
- aps-net
profiles:
- testsuite

astra-mongo:
image: mongo:4.2.2
image: mongo:4
container_name: astra-mongo
ports:
- '27017:27017'
networks:
aps-net:
aliases:
- mongo.localtest.me
profiles:
- testsuite

astra-gui:
build:
context: local/astra
Expand All @@ -263,5 +268,8 @@ services:
- astra-mongo:mongo
ports:
- '8094:8094'
profiles:
- testsuite

networks:
aps-net: {}
aps-net: {}
25 changes: 16 additions & 9 deletions e2e/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
FROM cypress/included:12.17.4

# Copy of the source for code coverage analysis
WORKDIR /app
COPY src/. ./

RUN npm install --legacy-peer-deps

RUN npx nyc instrument --compact=false . --in-place

# Cypress E2E
WORKDIR /e2e

RUN apt-get -y update; apt-get -y install curl
COPY package.json /e2e
COPY package-lock.json /e2e
COPY e2e/package.json /e2e
COPY e2e/package-lock.json /e2e
RUN npm install

COPY cypress.config.ts /e2e
COPY tsconfig.json /e2e
COPY *.yml /e2e
COPY entrypoint.sh /tmp
ADD cypress /e2e/cypress
COPY e2e/cypress.config.ts /e2e
COPY e2e/tsconfig.json /e2e
COPY e2e/*.yml /e2e
COPY e2e/entrypoint.sh /tmp
ADD e2e/cypress /e2e/cypress

RUN curl -v -L -O https://github.com/bcgov/gwa-cli/releases/download/v2.0.15/gwa_Linux_x86_64.tgz \
&& tar -xzf gwa_Linux_x86_64.tgz \
&& mv gwa /usr/local/bin/.



ENTRYPOINT ["npm", "run", "cy:run:html"]
59 changes: 34 additions & 25 deletions e2e/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,47 @@
import cypress, { defineConfig } from 'cypress'
//import plugins from './cypress/plugins/index.js'

const baseUrl = 'http://oauth2proxy.localtest.me:4180'

export default defineConfig({
env: {
codeCoverage: {
url: `${baseUrl}/__coverage__`,
exclude: 'e2e/**/*.*',
},
},
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
// require('@cypress/code-coverage/task')(on, config)
// // include any other plugin code...
require('dotenv').config()
require('@cypress/code-coverage/task')(on, config)

// // It's IMPORTANT to return the config object
// // with any changed environment variables
config.specPattern=[
'./cypress/tests/01-*/*.ts',
'./cypress/tests/02-*/*.ts',
'./cypress/tests/06-*/*.ts',
'./cypress/tests/07-*/*.ts',
'./cypress/tests/03-*/*.ts',
'./cypress/tests/04-*/*.ts',
'./cypress/tests/05-*/*.ts',
'./cypress/tests/08-*/*.ts',
'./cypress/tests/09-*/*.ts',
'./cypress/tests/10-*/*.ts',
'./cypress/tests/11-*/*.ts',
'./cypress/tests/12-*/*.ts',
'./cypress/tests/13-*/*.ts',
'./cypress/tests/14-*/*.ts',
'./cypress/tests/15-*/*.ts',
'./cypress/tests/16-*/*.ts',
'./cypress/tests/17-*/*.ts',
'./cypress/tests/18-*/*.ts'
]
config.specPattern = [
'./cypress/tests/01-*/*.ts',
'./cypress/tests/02-*/*.ts',
'./cypress/tests/06-*/*.ts',
'./cypress/tests/07-*/*.ts',
'./cypress/tests/03-*/*.ts',
'./cypress/tests/04-*/*.ts',
'./cypress/tests/05-*/*.ts',
'./cypress/tests/08-*/*.ts',
'./cypress/tests/09-*/*.ts',
'./cypress/tests/10-*/*.ts',
'./cypress/tests/11-*/*.ts',
'./cypress/tests/12-*/*.ts',
'./cypress/tests/13-*/*.ts',
'./cypress/tests/14-*/*.ts',
'./cypress/tests/15-*/*.ts',
'./cypress/tests/16-*/*.ts',
'./cypress/tests/17-*/*.ts',
'./cypress/tests/18-*/*.ts',
]
return config
},
baseUrl: 'http://oauth2proxy.localtest.me:4180',
baseUrl,
specPattern: 'cypress/tests/**/*.cy.ts',
screenshotOnRunFailure: true,
screenshotsFolder: 'results/report/assets',
Expand All @@ -59,11 +68,11 @@ export default defineConfig({
KONG_CONFIG_URL: 'http://kong.localtest.me:8001',
BASE_URL: 'http://oauth2proxy.localtest.me:4180',
KEYCLOAK_URL: 'http://keycloak.localtest.me:9081',
WEBAPP_URL: 'http://html-sample-app.localtest.me:4242'
WEBAPP_URL: 'http://html-sample-app.localtest.me:4242',
},
retries: {
runMode: 2,
openMode: 0,
}
},
},
})
File renamed without changes.
25 changes: 0 additions & 25 deletions e2e/cypress/plugins/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion e2e/cypress/tests/01-api-key/01-create-api.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ it('Verify gwa gateway publish multiple config file', () => {
})

it('Upload dataset and Product using GWA Apply command', () => {
cy.executeCliCommand('gwa apply -i gw-config.yml').then((response) => {
cy.executeCliCommand('gwa apply -i cypress/fixtures/gw-config.yml').then((response) => {
let wordOccurrences = (response.stdout.match(/\bcreated\b/g) || []).length;
expect(wordOccurrences).to.equal(2)
})
Expand Down
4 changes: 0 additions & 4 deletions e2e/cypress/tests/16-gwa-cli/01-cli-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ describe('Verify CLI commands', () => {
});
})

it('Delete Exsting config file', () => {
cy.deleteFileInE2EFolder('gw-config.yml')
})

after(() => {
cy.logout()
cy.clearLocalStorage({ log: true })
Expand Down
Loading
Loading