-
Notifications
You must be signed in to change notification settings - Fork 4
155 lines (125 loc) · 4.05 KB
/
ci.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
name: CI
on:
pull_request:
jobs:
pr-checks:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build:
runs-on: ubuntu-latest
env:
CODE_VERSION: ${{ vars.CODE_VERSION }}
ALGOLIA_APP_ID: ${{ vars.ALGOLIA_APP_ID }}
ALGOLIA_INDEX_NAME: ${{ vars.ALGOLIA_INDEX_NAME }}
SANDBOX_HOST: ${{ vars.SANDBOX_HOST }}
TEST_PRODUCT_ID: ${{ vars.TEST_PRODUCT_ID }}
SFCC_OAUTH_CLIENT_ID: ${{ secrets.SFCC_OAUTH_CLIENT_ID }}
SFCC_OAUTH_CLIENT_SECRET: ${{ secrets.SFCC_OAUTH_CLIENT_SECRET }}
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install Required Packages
run: |
sudo apt-get update
sudo apt-get install -y zip
- name: Install Dependencies
run: npm ci
- name: Compile JS and CSS
run: |
npm run compile:js
npm run compile:scss
- name: Create Code Version Directory
run: mkdir $CODE_VERSION
- name: Copy Cartridges
run: cp -R cartridges/* $CODE_VERSION/
- name: Package Code
run: zip -r $CODE_VERSION.zip $CODE_VERSION
- name: Deploy and Activate Code
env:
SANDBOX_HOST: ${{ vars.SANDBOX_HOST }}
CODE_VERSION: ${{ vars.CODE_VERSION }}
run: npm run deploy:code
- name: Import Site Preferences
env:
SANDBOX_HOST: ${{ vars.SANDBOX_HOST }}
run: npm run import:preferences
- name: Run SFCC Job
env:
SANDBOX_HOST: ${{ vars.SANDBOX_HOST }}
run: npm run run:sfcc-job
unit-tests-and-lints:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install Dependencies
run: npm ci
- name: Run Unit Tests
run: npm run test:unit
- name: Lint JavaScript
run: npm run lint:js
index-tests:
runs-on: ubuntu-latest
needs: build
env:
SFCC_OAUTH_CLIENT_ID: ${{ secrets.SFCC_OAUTH_CLIENT_ID }}
SFCC_OAUTH_CLIENT_SECRET: ${{ secrets.SFCC_OAUTH_CLIENT_SECRET }}
SANDBOX_HOST: ${{ vars.SANDBOX_HOST }}
ALGOLIA_APP_ID: ${{ vars.ALGOLIA_APP_ID }}
ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_KEY }}
ALGOLIA_INDEX_NAME: ${{ vars.ALGOLIA_INDEX_NAME }}
TEST_PRODUCT_ID: ${{ vars.TEST_PRODUCT_ID }}
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Create dw.json file
run: |
echo '{
"client-id": "'"${{ secrets.SFCC_OAUTH_CLIENT_ID }}"'",
"client-secret": "'"${{ secrets.SFCC_OAUTH_CLIENT_SECRET }}"'",
"hostname": "'"${{ vars.SANDBOX_HOST }}"'"
}' > dw.json
- name: Install sfcc-ci
run: sudo npm install -g sfcc-ci
- name: Authenticate with SFCC
run: |
sfcc-ci client:auth "$SFCC_OAUTH_CLIENT_ID" "$SFCC_OAUTH_CLIENT_SECRET"
echo "ACCESS_TOKEN=$(sfcc-ci client:auth:token)" >> $GITHUB_ENV
- name: Install Dependencies
run: npm ci
- name: Install Algolia Dependencies
run: npm install algoliasearch
- name: Run Algolia Index Tests
run: npm run test:variationindex
frontend-tests:
runs-on: ubuntu-latest
needs: [build, index-tests]
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Run Cypress Tests
uses: cypress-io/github-action@v6
with:
install: npm ci
browser: electron
headless: true
config-file: cypress.config.js
env:
CYPRESS_SANDBOX_HOST: ${{ vars.SANDBOX_HOST }}
SANDBOX_HOST: ${{ vars.SANDBOX_HOST }}