-
Notifications
You must be signed in to change notification settings - Fork 13
148 lines (123 loc) · 4.46 KB
/
main.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
name: E2E Tests
on:
push:
branches:
- '**' # matches every branch
- '!main' # excludes main
jobs:
shellspec_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]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '1.19'
- name: Build Golang CLI
run: go build -o snyk-iac-rules .
- name: Login to Docker Hub
uses: docker/login-action@v1
if: ${{ matrix.os != 'macos' }}
with:
username: ${{ secrets.OCI_REGISTRY_USERNAME }}
password: ${{ secrets.OCI_REGISTRY_PASSWORD }}
- name: Install Shellspec - non-Windows
if: ${{ matrix.os != 'windows' }}
run: |
curl -fsSL https://git.io/shellspec | sh -s -- -y
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 Shellspec - Windows
shell: powershell
if: ${{ matrix.os == 'windows' }}
run: |
Get-Host | Select-Object Version
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
sh ./scripts/install-shellspec-win.sh
- name: Run shellspec tests - Ubuntu
if: ${{ matrix.os == 'ubuntu'}}
working-directory: ./
shell: bash -l {0} # run bash with --login flag to load .bash_profile that's used by yarn install method
run: |
export PATH="/usr/local/bin/snyk-mac/docker:$PATH"
shellspec "spec/e2e"
env:
SKIP_PUSH_TEST: true # Oras copy is intermittently failing on Ubuntu with "cannot reuse body, request must be retried"
OCI_REGISTRY_NAME: ${{ secrets.OCI_REGISTRY_NAME }}
- name: Run shellspec tests - MacOS
if: ${{ matrix.os == 'macos'}}
working-directory: ./
shell: bash -l {0} # run bash with --login flag to load .bash_profile that's used by yarn install method
run: |
export PATH=${GOROOT}/bin:$PATH
shellspec "spec/e2e"
env:
SKIP_PUSH_TEST: true # Docker is not supported in MacOS: https://github.com/docker/login-action/issues/14
- name: Run shellspec tests - Windows
if: ${{ matrix.os == 'windows' }}
working-directory: ./
shell: powershell
run: |
sh ./scripts/run-e2e-win.sh
env:
OCI_REGISTRY_NAME: ${{ secrets.OCI_REGISTRY_NAME }}
npm_install_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]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '1.19'
- name: Install NPM package - non-Windows
if: ${{ matrix.os != 'windows' }}
run: |
./scripts/release-npm.sh --tag=v0.0.1
npm i -g ./dist
# verifies that the installation works
snyk-iac-rules
- name: Install NPM package - Windows
shell: powershell
if: ${{ matrix.os == 'windows' }}
run: |
Get-Host | Select-Object Version
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
sh ./scripts/release-npm.sh --tag=v0.0.1
npm install -g npm
npm install -g ./dist
# verifies that the installation works
snyk-iac-rules
docker_build_and_run_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]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-go@v2
with:
go-version: 1.19
- name: Build binaries
uses: goreleaser/goreleaser-action@v2
with:
args: --snapshot --clean
- name: Test Dockerfile
run: |
docker run snyk/snyk-iac-rules:latest