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

wip: debugging smoke tests #38

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
218 changes: 109 additions & 109 deletions .github/workflows/smoke_tests.yaml
Original file line number Diff line number Diff line change
@@ -1,109 +1,109 @@
name: Smoke Tests
on:
push:
branches:
- master
pull_request:

jobs:
smoke_tests:
name: Smoke tests @ Nexus ${{ matrix.nexus_version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
nexus_version: [3.34.1]

steps:
- name: Fetch sources
uses: actions/checkout@v2

- name: Setup JDK 8
uses: actions/setup-java@v1
with:
java-version: 8

- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: |
~/.m2/repository
~/.m2/wrapper
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Configure build metadata
id: metadata
run: echo ::set-output name=tag::1.0.0

- name: Install Cypress
run: npm install -g cypress@9.7.0

- name: Build plugin
env:
TEST_SNYK_TOKEN: ${{ secrets.TEST_SNYK_TOKEN }}
TEST_SNYK_ORG: ${{ secrets.TEST_SNYK_ORG }}
run: |
./mvnw clean verify -DskipTests --show-version --batch-mode --errors -PbuildKar -Drevision=${{ steps.metadata.outputs.tag }}
ls -la ${GITHUB_WORKSPACE}/plugin/target/nexus-snyk-security-plugin-bundle.kar

- name: Start the Nexus container with Snyk plugin mounted
run: docker run -d --name nexus -p 8081:8081 -v ${GITHUB_WORKSPACE}/plugin/target/nexus-snyk-security-plugin-bundle.kar:/opt/sonatype/nexus/deploy/nexus-snyk-security-plugin-bundle.kar sonatype/nexus3

- name: Wait for Nexus start
run: npx wait-on --timeout 120000 --interval 2000 http://localhost:8081/

- name: Wait for API status endpoint
run: npx wait-on --timeout 120000 --interval 2000 http://localhost:8081/service/rest/v1/status/writable

- name: Run Cypress to log in to Nexus and set up Snyk plugin
working-directory: test/smoke
run: |
docker exec nexus cat /nexus-data/admin.password > /tmp/password
export NEXUS_PASS=$(cat /tmp/password)
echo $NEXUS_PASS
cat /tmp/password
cypress run
env:
TEST_SNYK_TOKEN: ${{ secrets.TEST_SNYK_TOKEN }}
TEST_SNYK_ORG: ${{ secrets.TEST_SNYK_ORG }}

- name: Setup npm
run: npm install

- name: Lint Node.js
run: npm run lint:formatting

- name: Run Jest tests against running Nexus
run: |
export NEXUS_PASS=$(cat /tmp/password)
npm run test

- uses: actions/upload-artifact@v2
if: always()
with:
name: screenshots
path: /home/runner/work/nexus-snyk-security-plugin/nexus-snyk-security-plugin/test/smoke/cypress/screenshots/cypress-test.spec.js/
retention-days: 1

- uses: actions/upload-artifact@v2
if: always()
with:
name: video
path: /home/runner/work/nexus-snyk-security-plugin/nexus-snyk-security-plugin/test/smoke/cypress/videos/cypress-test.spec.js.mp4
retention-days: 1

- name: Save docker logs to file
uses: jwalton/gh-docker-logs@v1
with:
dest: "./logs"

- name: Find any Snyk plugin errors in docker logs
run: "! grep -Hrni snyk ./logs | grep -i error"

- name: Dump docker logs (on success)
uses: jwalton/gh-docker-logs@v1

- name: Dump docker logs (on failure)
if: failure()
uses: jwalton/gh-docker-logs@v1
name: Smoke Tests
on:
push:
branches:
- master
pull_request:

jobs:
smoke_tests:
name: Smoke tests @ Nexus ${{ matrix.nexus_version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
nexus_version: [3.34.1]

steps:
- name: Fetch sources
uses: actions/checkout@v2

- name: Setup JDK 8
uses: actions/setup-java@v1
with:
java-version: 8

- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: |
~/.m2/repository
~/.m2/wrapper
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Configure build metadata
id: metadata
run: echo ::set-output name=tag::1.0.0

- name: Install Cypress
run: npm install -g cypress@13.3.1

- name: Build plugin
env:
TEST_SNYK_TOKEN: ${{ secrets.TEST_SNYK_TOKEN }}
TEST_SNYK_ORG: ${{ secrets.TEST_SNYK_ORG }}
run: |
./mvnw clean verify -DskipTests --show-version --batch-mode --errors -PbuildKar -Drevision=${{ steps.metadata.outputs.tag }}
ls -la ${GITHUB_WORKSPACE}/plugin/target/nexus-snyk-security-plugin-bundle.kar

- name: Start the Nexus container with Snyk plugin mounted
run: docker run -d --name nexus -p 8081:8081 -v ${GITHUB_WORKSPACE}/plugin/target/nexus-snyk-security-plugin-bundle.kar:/opt/sonatype/nexus/deploy/nexus-snyk-security-plugin-bundle.kar sonatype/nexus3

- name: Wait for Nexus start
run: npx wait-on --timeout 120000 --interval 2000 http://localhost:8081/

- name: Wait for API status endpoint
run: npx wait-on --timeout 120000 --interval 2000 http://localhost:8081/service/rest/v1/status/writable

- name: Run Cypress to log in to Nexus and set up Snyk plugin
working-directory: test/smoke
run: |
docker exec nexus cat /nexus-data/admin.password > /tmp/password
export NEXUS_PASS=$(cat /tmp/password)
echo $NEXUS_PASS
cat /tmp/password
cypress run
env:
TEST_SNYK_TOKEN: ${{ secrets.TEST_SNYK_TOKEN }}
TEST_SNYK_ORG: ${{ secrets.TEST_SNYK_ORG }}

- name: Setup npm
run: npm install

- name: Lint Node.js
run: npm run lint:formatting

- name: Run Jest tests against running Nexus
run: |
export NEXUS_PASS=$(cat /tmp/password)
npm run test

- uses: actions/upload-artifact@v2
if: always()
with:
name: screenshots
path: /home/runner/work/nexus-snyk-security-plugin/nexus-snyk-security-plugin/test/smoke/cypress/screenshots/cypress-test.cy.js/test
retention-days: 1

- uses: actions/upload-artifact@v2
if: always()
with:
name: video
path: /home/runner/work/nexus-snyk-security-plugin/nexus-snyk-security-plugin/test/smoke/cypress/videos/cypress-test.cy.js.mp4
retention-days: 1

- name: Save docker logs to file
uses: jwalton/gh-docker-logs@v1
with:
dest: "./logs"

- name: Find any Snyk plugin errors in docker logs
run: "! grep -Hrni snyk ./logs | grep -i error"

- name: Dump docker logs (on success)
uses: jwalton/gh-docker-logs@v1

- name: Dump docker logs (on failure)
if: failure()
uses: jwalton/gh-docker-logs@v1
12 changes: 12 additions & 0 deletions test/smoke/cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
defaultCommandTimeout: 20000,
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
return require('./cypress/plugins/index.js')(on, config);
},
supportFile: false,
video: true,
},
};
3 changes: 0 additions & 3 deletions test/smoke/cypress.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe("test", () => {
"This wizard will help you complete required setup tasks."
).should("be.visible");

// Go through the mandatory wizard to set a new password (same as the old password)
// Go through the mandatory wizard to set a new password (same as the old password)
cy.get("body").then(($body) => {
if ($body.find('div[role="dialog"]').length) {
cy.log("found the wizard");
Expand All @@ -26,7 +26,8 @@ describe("test", () => {
cy.log("in the diaglog callback");
if ($dialog.find("a").length) {
cy.log("found the Next button");
cy.wrap($dialog).should("be.visible").contains("Next").click();
// cy.wrap($dialog).should("be.visible").contains("Next").click();
cy.contains("Next").click();
cy.log("clicked the Next button");

// Set new password
Expand Down Expand Up @@ -56,12 +57,13 @@ describe("test", () => {
cy.log("found an anonymous access radio button");
cy.wrap($anonymous).get('div[role="radiogroup"] input').check();
cy.log("checked the first anonymous access radio buttong");
cy.contains(
'div[role="dialog"] a[role="button"]:visible',
"Next"
).click();
cy.log("clicked the Next button");
}

cy.contains(
'div[role="dialog"] a[role="button"]:visible',
"Next"
).click();
cy.log("clicked the Next button");
});

// Finish
Expand All @@ -82,12 +84,14 @@ describe("test", () => {
cy.get('a[data-qtip="Server administration and configuration"]').click();
cy.contains('td[role="gridcell"]', "System").click();
cy.contains('div[role="option"]', "Capabilities").click();
cy.contains("Loading").should("not.be.visible");
cy.contains('a[role="button"]', "Create capability").click();
cy.contains("Loading").should("not.be.visible");
cy.contains("Select Capability Type").should("be.visible");
cy.contains("td:visible", "Snyk Security Configuration")
.should("be.visible")
.click();
.should("be.visible")
.click();
cy.contains("Loading").should("not.be.visible");
cy.get('input[name="property_snyk.api.token"]')
.should("be.visible")
.type(Cypress.env("snykToken"));
Expand Down
3 changes: 2 additions & 1 deletion test/the.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ it('throws when trying to download a vulnerable package', async () => {
);

let capturedErr;
let res;

try {
const res = await axios.get(url, {
res = await axios.get(url, {
headers: {
Authorization: `Basic ${nexusAuth}`,
},
Expand Down
Loading