Skip to content

Commit

Permalink
Merge pull request #1502 from snyk/smoke/docker-root
Browse files Browse the repository at this point in the history
test(smoke): scenario where root user installing Snyk
  • Loading branch information
JackuB committed Nov 4, 2020
2 parents cb5beb9 + c095596 commit 32f23aa
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/smoke-tests.yml
Expand Up @@ -47,6 +47,8 @@ jobs:
- snyk_install_method: alpine-binary
os: ubuntu
snyk_cli_dl_file: snyk-alpine
- snyk_install_method: npm-root-user
os: ubuntu

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -85,6 +87,14 @@ jobs:
docker build -t snyk-cli-alpine -f ./test/smoke/alpine/Dockerfile ./test
docker run -eCI=1 -eSMOKE_TESTS_SNYK_TOKEN snyk-cli-alpine
- name: Run npm test with Root user
if: ${{ matrix.snyk_install_method == 'npm-root-user' }}
env:
SMOKE_TESTS_SNYK_TOKEN: ${{ secrets.SMOKE_TESTS_SNYK_TOKEN }}
run: |
docker build -t snyk-docker-root -f ./test/smoke/docker-root/Dockerfile ./test
docker run -eCI=1 -eSMOKE_TESTS_SNYK_TOKEN snyk-docker-root
- name: Install Snyk with binary - Non-Windows
if: ${{ matrix.snyk_install_method == 'binary' && matrix.os != 'windows' }}
run: |
Expand Down Expand Up @@ -138,7 +148,7 @@ jobs:
scoop install jq
- name: Install jq on Ubuntu
if: ${{ matrix.os == 'ubuntu' && matrix.snyk_install_method != 'alpine-binary'}}
if: ${{ matrix.os == 'ubuntu' && matrix.snyk_install_method != 'alpine-binary' && matrix.snyk_install_method != 'npm-root-user' }}
run: |
sudo apt-get install jq
Expand All @@ -151,7 +161,7 @@ jobs:
sh ./test/smoke/install-shellspec-win.sh
- name: Run shellspec tests - non-Windows
if: ${{ matrix.os != 'windows' && matrix.snyk_install_method != 'alpine-binary'}}
if: ${{ matrix.os != 'windows' && matrix.snyk_install_method != 'alpine-binary' && matrix.snyk_install_method != 'npm-root-user' }}
working-directory: test/smoke
shell: bash -l {0} # run bash with --login flag to load .bash_profile that's used by yarn install method
env:
Expand Down
12 changes: 12 additions & 0 deletions test/smoke/docker-root/Dockerfile
@@ -0,0 +1,12 @@
FROM node:12

COPY ./smoke/ /snyk/smoke/
COPY ./fixtures/ /snyk/fixtures/

RUN apt-get update && apt-get install -y curl jq
RUN curl -fsSL https://git.io/shellspec | sh -s -- --yes
ENV PATH="/root/.local/bin:${PATH}"

WORKDIR /snyk/smoke/

ENTRYPOINT [ "./docker-root/entrypoint.sh" ]
11 changes: 11 additions & 0 deletions test/smoke/docker-root/entrypoint.sh
@@ -0,0 +1,11 @@
#!/bin/sh

set -e

echo "Install Snyk CLI with npm"
npm install snyk -g
snyk --version

export EXPECTED_SNYK_VERSION=$(snyk --version)

shellspec -f d

0 comments on commit 32f23aa

Please sign in to comment.