-
Notifications
You must be signed in to change notification settings - Fork 565
196 lines (176 loc) · 7.03 KB
/
smoke-tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
name: Smoke Tests
on:
push:
branches: [feat/smoke-test, smoke/**]
release:
types: [published]
schedule:
- cron: '0 23 * * *'
jobs:
smoke_test:
# The type of runner that the job will run on
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false # we care about other platforms and channels building
matrix:
os: [ubuntu, macos, windows]
snyk_install_method: [binary, npm, yarn, brew]
node_version: [14, 16]
exclude:
# Skip yarn for Windows, as it's a bit crazy to get it working in CI environment. Unless we see evidence we need it, I'd avoid it
- snyk_install_method: yarn
os: windows
# For binary, use only the Node 14
- snyk_install_method: binary
node_version: 12
- snyk_install_method: binary
node_version: 16
# No need to run brew tests on some Platforms
- snyk_install_method: brew
os: ubuntu
- snyk_install_method: brew
os: windows
include:
- snyk_install_method: binary
os: ubuntu
snyk_cli_dl_file: snyk-linux
- snyk_install_method: binary
os: macos
snyk_cli_dl_file: snyk-macos
- snyk_install_method: alpine-binary
os: ubuntu
node_version: 16
snyk_cli_dl_file: snyk-alpine
- snyk_install_method: npm-root-user
os: ubuntu
node_version: 16
- snyk_install_method: docker-bundle
os: macos
node_version: 16
snyk_cli_dl_file: snyk-for-docker-desktop-darwin-x64.tar.gz
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1 # Needed for fixtures installation
with:
node-version: ${{ matrix.node_version }}
- name: Install Snyk with npm
if: ${{ matrix.snyk_install_method == 'npm' }}
run: |
echo "node_version: ${{ matrix.node_version }}"
node -v
echo "install snyk with npm"
npm install -g snyk
- name: Install Snyk with Yarn globally
if: ${{ matrix.snyk_install_method == 'yarn' }}
run: |
npm install yarn -g
echo "Yarn global path"
yarn global bin
echo 'export PATH="$PATH:$(yarn global bin)"' >> ~/.bash_profile
yarn global add snyk
- name: npm install for fixture project
working-directory: test/fixtures/basic-npm
run: |
npm install
- name: Run alpine test
if: ${{ matrix.snyk_install_method == 'alpine-binary' }}
env:
SMOKE_TESTS_SNYK_TOKEN: ${{ secrets.SMOKE_TESTS_SNYK_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
docker build -t snyk-cli-alpine -f ./test/smoke/alpine/Dockerfile ./test
docker run -eCI=1 -eSMOKE_TESTS_SNYK_TOKEN -eGITHUB_TOKEN snyk-cli-alpine
- name: Install snyk from Docker bundle
if: ${{ matrix.snyk_install_method == 'docker-bundle' && matrix.os == 'macos' }}
run: |
pushd "$(mktemp -d)"
curl 'https://static.snyk.io/cli/latest/${{ matrix.snyk_cli_dl_file }}' | tar -xz
pushd ./docker
ls -la
sudo ln -s "$(pwd)/snyk-mac.sh" ./snyk
export PATH="$(pwd):${PATH}"
echo "$(pwd)" >> "${GITHUB_PATH}"
popd
popd
which snyk
snyk version
- 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: |
curl -Lo ./snyk-cli 'https://static.snyk.io/cli/latest/${{ matrix.snyk_cli_dl_file }}'
chmod -R +x ./snyk-cli
sudo mv ./snyk-cli /usr/local/bin/snyk
snyk --version
- name: Install Snyk with binary - Windows
if: ${{ matrix.snyk_install_method == 'binary' && matrix.os == 'windows' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: powershell
run: |
echo "install snyk with binary"
echo $env:PATH
sh ./test/smoke/install-snyk-binary-win.sh
- name: Install Shellspec - non-windows
if: ${{ matrix.os != 'windows' && matrix.snyk_install_method != 'alpine-binary' }}
run: |
./test/smoke/install-shellspec.sh --yes
sudo ln -s ${HOME}/.local/lib/shellspec/shellspec /usr/local/bin/shellspec
ls -la ${HOME}/.local/lib/shellspec
echo "shellspec symlink:"
ls -la /usr/local/bin/shellspec
/usr/local/bin/shellspec --version
which shellspec
shellspec --version
- name: Install test utilities with homebrew on macOS
if: ${{ matrix.os == 'macos' }}
# We need "timeout" and "jq" util and we'll use brew to check our brew package as well
run: |
brew install coreutils
brew install jq
- name: Install Snyk CLI with homebrew on macOS
if: ${{ matrix.snyk_install_method == 'brew' && matrix.os == 'macos'}}
run: |
brew tap snyk/tap
brew install snyk
- name: Install scoop on Windows
if: ${{ matrix.os == 'windows'}}
run: |
iwr -useb get.scoop.sh -outfile 'install-scoop.ps1'
.\install-scoop.ps1 -RunAsAdmin
scoop install jq
- name: Install jq on Ubuntu
if: ${{ matrix.os == 'ubuntu' && matrix.snyk_install_method != 'alpine-binary' && matrix.snyk_install_method != 'npm-root-user' }}
run: |
sudo apt-get install jq
- name: Install Shellspec - Windows
shell: powershell
if: ${{ matrix.os == 'windows' }}
run: |
Get-Host | Select-Object Version
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
sh ./test/smoke/install-shellspec.sh --yes
- name: Run shellspec tests - non-Windows
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:
SMOKE_TESTS_SNYK_TOKEN: ${{ secrets.SMOKE_TESTS_SNYK_TOKEN }}
run: |
which snyk
snyk version
shellspec -f d --skip-message quiet --no-warning-as-failure
- name: Run shellspec tests - Windows
if: ${{ matrix.os == 'windows' }}
working-directory: test/smoke
shell: powershell
env:
SMOKE_TESTS_SNYK_TOKEN: ${{ secrets.SMOKE_TESTS_SNYK_TOKEN }}
run: |
sh ./run-shellspec-win.sh