forked from sanity-io/sanity
-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (64 loc) · 2.43 KB
/
test.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
name: Test
on: [push]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x, 12.x, 14.x]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Cache node modules
uses: actions/cache@v2
env:
# added -vX just to reset the cache, feel free to up it if you need
# to reset the cache again
cache-name: cache-node-modules-v4
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
- name: Install npm dependencies
run: npm install
- name: Build modules
run: npm run build
- name: Test individual modules
run: npx lerna run test --concurrency 2 --stream
- name: Build CLI
run: |
# Build CLI to a single file
cd packages/@sanity/cli
npm run pack
# Remove source and dependencies from CLI to ensure it works standalone
rm -rf packages/@sanity/cli/node_modules
rm -rf packages/@sanity/cli/src && rm -rf packages/@sanity/cli/lib
# Allow running the Sanity CLI tool without specifying absolute path
echo "${GITHUB_WORKSPACE}/packages/@sanity/cli/bin" >> $GITHUB_PATH
- name: Test sanity build command
run: |
# Test building the test studio with all customizations
cd $GITHUB_WORKSPACE/examples/test-studio
sanity build -y
- name: Test sanity init command
run: |
# Test initializing a project in unattended mode
cd /tmp
sanity init -y --project=ppsg7ml5 --dataset=test --output-path=/tmp/test-project
- name: Test build with new code
run: |
# Use the newly commited changes instead of the latest dependencies from NPM
cd /tmp/test-project
$GITHUB_WORKSPACE/scripts/symlinkDependencies.js .
# Test building the project with latest dependencies
sanity build --skip-minify
- name: Notify Slack about build failure
if: failure() && github.ref == 'refs/heads/ui/main'
env:
SLACK_BOT_TOKEN: ${{ secrets.ACTIONS_SLACK_BOT_TOKEN }}
uses: voxmedia/github-action-slack-notify-build@v1
with:
channel: prj-components
status: FAILED
color: danger