Skip to content

Commit

Permalink
Merge pull request snyk#1433 from snyk/feat/smoke-test
Browse files Browse the repository at this point in the history
Cleaner Smoke test output
  • Loading branch information
JackuB committed Oct 5, 2020
2 parents 282d8d3 + 3d383cf commit 7c7d579
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/smoke-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Smoke Tests

on:
push:
branches: [feat/smoke-test]
branches: [feat/smoke-test, smoke/**]
release:
types: [published]
schedule:
Expand Down
13 changes: 7 additions & 6 deletions dangerfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ if (danger.github && danger.github.pr) {
}

// Forgotten tests check
const modifiedTest = danger.git.modified_files.some((f) =>
f.startsWith('test/'),
);
const modifiedSrc = danger.git.modified_files.some((f) =>
f.startsWith('src/'),
);
const modifiedTest =
danger.git.modified_files.some((f) => f.startsWith('test/')) ||
danger.git.created_files.some((f) => f.startsWith('test/'));
const modifiedSrc =
danger.git.modified_files.some((f) => f.startsWith('src/')) ||
danger.git.created_files.some((f) => f.startsWith('src/'));

if (modifiedSrc && !modifiedTest) {
// TODO: let's be careful about wording here. Maybe including Contributing guidelines and project goals document here
Expand All @@ -54,6 +54,7 @@ if (danger.github && danger.github.pr) {
// Smoke test modification check
const modifiedSmokeTest =
danger.git.modified_files.some((f) => f.startsWith('test/smoke/')) ||
danger.git.created_files.some((f) => f.startsWith('test/smoke/')) ||
danger.git.modified_files.includes(SMOKE_TEST_WORKFLOW_FILE_PATH);

const isOnSmokeTestBranch = danger.github.pr.head.ref === SMOKE_TEST_BRANCH;
Expand Down
2 changes: 1 addition & 1 deletion test/smoke/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Smoke tests should be fast. Ideally tests only things that could break when CLI

Before you start adding specs, those files are bash scripts, it's recommended to have a [ShellCheck](https://www.shellcheck.net) installed and running in your IDE. See [Shellspec reference](https://github.com/shellspec/shellspec/blob/master/docs/references.md#expectation) for available commands.

It's recommended to have a branch named `feat/smoke-test`, as [this branch will run the GitHub Action](https://github.com/snyk/snyk/blob/f35f39e96ef7aa69b22a846315dda015b12a4564/.github/workflows/smoke-tests.yml#L3-L5).
It's recommended to have a branch named `smoke/_SOMETHING_`, as [this branch will run the GitHub Action](https://github.com/snyk/snyk/blob/f35f39e96ef7aa69b22a846315dda015b12a4564/.github/workflows/smoke-tests.yml#L3-L5).

To run these tests locally:

Expand Down
4 changes: 1 addition & 3 deletions test/smoke/alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
FROM shellspec/shellspec:latest

COPY ./smoke/ /snyk/smoke/
COPY ./fixtures/basic-npm/ /snyk/fixtures/basic-npm/
COPY ./fixtures/empty/ /snyk/fixtures/empty/
COPY ./fixtures/iac/ /snyk/fixtures/iac/
COPY ./fixtures/ /snyk/fixtures/

RUN shellspec --version
RUN apk add curl jq libgcc libstdc++
Expand Down
5 changes: 4 additions & 1 deletion test/smoke/spec/snyk_auth_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ Describe "Snyk CLI Authorization"

It "fails when run without token set"
# Alpine can't open browser, misses xdg-open utility and errors out
is_alpine() { grep "Alpine Linux" < /etc/os-release; }
is_alpine() {
grep "Alpine Linux" /etc/os-release > /dev/null 2>&1
return $?
}
Skip if "function returns success" is_alpine

# Using timeout to not wait for browser confirmation
Expand Down
4 changes: 2 additions & 2 deletions test/smoke/spec/spec_helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ print_snyk_config() {
}

snyk_login() {
snyk auth "${SMOKE_TESTS_SNYK_TOKEN}"
snyk auth "${SMOKE_TESTS_SNYK_TOKEN}" > /dev/null 2>&1
}

snyk_logout() {
snyk config clear
snyk config clear > /dev/null 2>&1
}

verify_login_url() {
Expand Down

0 comments on commit 7c7d579

Please sign in to comment.