Skip to content

Commit 7c9efa0

Browse files
authored
refactor Semaphore (#90)
* refactor Semaphore * update directory
1 parent 6074a96 commit 7c9efa0

File tree

3 files changed

+36
-61
lines changed

3 files changed

+36
-61
lines changed

.semaphore/npm.yml

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version: v1.0
22

3-
name: NPM deployment
3+
name: Publish to NPM
44
agent:
55
machine:
66
type: e1-standard-2
@@ -11,9 +11,12 @@ blocks:
1111
task:
1212
secrets:
1313
- name: workos-npm
14+
prologue:
15+
commands:
16+
- checkout
17+
- nvm use
18+
- yarn install
1419
jobs:
15-
- name: Publish to NPM
20+
- name: yarn publish
1621
commands:
17-
- checkout
18-
- yarn install
1922
- yarn publish --access=public

.semaphore/semaphore.yml

+15-57
Original file line numberDiff line numberDiff line change
@@ -2,89 +2,47 @@ version: v1.0
22
name: workos-node pipeline
33

44
execution_time_limit:
5-
minutes: 15
5+
minutes: 10
66

77
agent:
88
machine:
99
type: e1-standard-2
1010
os_image: ubuntu1804
1111

1212
global_job_config:
13+
env_vars:
14+
- name: NODE_ENV
15+
value: test
1316
prologue:
1417
commands:
1518
- checkout
1619
- nvm use
20+
- bash ~/workos-node/bin/restore-or-install
1721

1822
blocks:
1923
- name: Install dependencies
24+
dependencies: []
2025
task:
21-
secrets:
22-
- name: workos-npm
23-
env_vars:
24-
- name: NODE_ENV
25-
value: test
26-
- name: CI
27-
value: 'true'
2826
jobs:
2927
- name: yarn install and cache
3028
commands:
31-
- cache restore client-node-modules-$SEMAPHORE_GIT_BRANCH-$(checksum yarn.lock),client-node-modules-$SEMAPHORE_GIT_BRANCH,client-node-modules-master
32-
- yarn install
33-
- cache store client-node-modules-$SEMAPHORE_GIT_BRANCH-$(checksum yarn.lock) node_modules
29+
- ls -d node_modules
3430

35-
- name: Lint
31+
- name: Test
32+
dependencies: ['Install dependencies']
3633
task:
37-
secrets:
38-
- name: workos-npm
39-
env_vars:
40-
- name: NODE_ENV
41-
value: test
42-
- name: CI
43-
value: 'true'
4434
jobs:
45-
- name: Run lint
35+
- name: yarn prettier
4636
commands:
47-
- cache restore client-node-modules-$SEMAPHORE_GIT_BRANCH-$(checksum yarn.lock),client-node-modules-$SEMAPHORE_GIT_BRANCH,client-node-modules-master
48-
- yarn lint
49-
50-
- name: Formatting
51-
task:
52-
secrets:
53-
- name: workos-npm
54-
env_vars:
55-
- name: NODE_ENV
56-
value: test
57-
- name: CI
58-
value: 'true'
59-
jobs:
60-
- name: Run prettier
61-
commands:
62-
- cache restore client-node-modules-$SEMAPHORE_GIT_BRANCH-$(checksum yarn.lock),client-node-modules-$SEMAPHORE_GIT_BRANCH,client-node-modules-master
6337
- yarn prettier
64-
65-
- name: Tests
66-
task:
67-
secrets:
68-
- name: workos-npm
69-
env_vars:
70-
- name: NODE_ENV
71-
value: test
72-
- name: CI
73-
value: 'true'
74-
jobs:
75-
- name: Run tests
38+
- name: yarn lint
39+
commands:
40+
- yarn lint
41+
- name: yarn test
7642
commands:
77-
- cache restore client-node-modules-$SEMAPHORE_GIT_BRANCH-$(checksum yarn.lock),client-node-modules-$SEMAPHORE_GIT_BRANCH,client-node-modules-master
7843
- yarn test
79-
80-
- name: Build
81-
task:
82-
secrets:
83-
- name: workos-npm
84-
jobs:
85-
- name: Run build
44+
- name: yarn build
8645
commands:
87-
- cache restore client-node-modules-$SEMAPHORE_GIT_BRANCH-$(checksum yarn.lock),client-node-modules-$SEMAPHORE_GIT_BRANCH,client-node-modules-master
8846
- yarn build
8947

9048
promotions:

bin/restore-or-install

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
KEY="node-modules-$(checksum yarn.lock)"
4+
cache restore $KEY
5+
6+
if [[ ! `ls -d ./node_modules 2>/dev/null` ]]; then
7+
yarn install
8+
cache store $KEY ./node_modules
9+
fi
10+
11+
if [[ ! `ls -d ./node_modules/.bin 2>/dev/null` ]]; then
12+
yarn install --check-files
13+
cache store $KEY ./node_modules
14+
fi

0 commit comments

Comments
 (0)