Smoke Tests #25717
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Smoke Tests | |
on: | |
push: | |
branches: [feat/smoke-test, smoke/**] | |
release: | |
types: [published] | |
schedule: | |
- cron: '0 23 * * *' | |
workflow_dispatch: | |
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: [18, 20] | |
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 18 | |
- snyk_install_method: binary | |
node_version: 18 | |
# 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: 18 | |
snyk_cli_dl_file: snyk-alpine | |
- snyk_install_method: npm-root-user | |
os: ubuntu | |
node_version: 18 | |
- snyk_install_method: docker-bundle | |
os: macos | |
node_version: 18 | |
snyk_cli_dl_file: snyk-for-docker-desktop-darwin-x64.tar.gz | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-node@v4 # 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: | |
TEST_SNYK_TOKEN: ${{ secrets.TEST_SNYK_TOKEN }} | |
TEST_SNYK_API: ${{ secrets.TEST_SNYK_API }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
docker build -t snyk-cli-alpine -f ./test/smoke/alpine/Dockerfile ./test | |
docker run -eCI=1 -eTEST_SNYK_TOKEN -eGITHUB_TOKEN -eTEST_SNYK_API 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://downloads.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: | |
TEST_SNYK_TOKEN: ${{ secrets.TEST_SNYK_TOKEN }} | |
TEST_SNYK_API: ${{ secrets.TEST_SNYK_API }} | |
run: | | |
docker build -t snyk-docker-root -f ./test/smoke/docker-root/Dockerfile ./test | |
docker run -eCI=1 -eTEST_SNYK_TOKEN -eTEST_SNYK_API 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://downloads.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: | |
TEST_SNYK_TOKEN: ${{ secrets.TEST_SNYK_TOKEN }} | |
TEST_SNYK_API: ${{ secrets.TEST_SNYK_API }} | |
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: | |
TEST_SNYK_TOKEN: ${{ secrets.TEST_SNYK_TOKEN }} | |
TEST_SNYK_API: ${{ secrets.TEST_SNYK_API }} | |
run: | | |
sh ./run-shellspec-win.sh |