Skip to content

Commit

Permalink
refactor Semaphore (#90)
Browse files Browse the repository at this point in the history
* refactor Semaphore

* update directory
  • Loading branch information
marktran authored Mar 13, 2020
1 parent 6074a96 commit 7c9efa0
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 61 deletions.
11 changes: 7 additions & 4 deletions .semaphore/npm.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: v1.0

name: NPM deployment
name: Publish to NPM
agent:
machine:
type: e1-standard-2
Expand All @@ -11,9 +11,12 @@ blocks:
task:
secrets:
- name: workos-npm
prologue:
commands:
- checkout
- nvm use
- yarn install
jobs:
- name: Publish to NPM
- name: yarn publish
commands:
- checkout
- yarn install
- yarn publish --access=public
72 changes: 15 additions & 57 deletions .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,89 +2,47 @@ version: v1.0
name: workos-node pipeline

execution_time_limit:
minutes: 15
minutes: 10

agent:
machine:
type: e1-standard-2
os_image: ubuntu1804

global_job_config:
env_vars:
- name: NODE_ENV
value: test
prologue:
commands:
- checkout
- nvm use
- bash ~/workos-node/bin/restore-or-install

blocks:
- name: Install dependencies
dependencies: []
task:
secrets:
- name: workos-npm
env_vars:
- name: NODE_ENV
value: test
- name: CI
value: 'true'
jobs:
- name: yarn install and cache
commands:
- cache restore client-node-modules-$SEMAPHORE_GIT_BRANCH-$(checksum yarn.lock),client-node-modules-$SEMAPHORE_GIT_BRANCH,client-node-modules-master
- yarn install
- cache store client-node-modules-$SEMAPHORE_GIT_BRANCH-$(checksum yarn.lock) node_modules
- ls -d node_modules

- name: Lint
- name: Test
dependencies: ['Install dependencies']
task:
secrets:
- name: workos-npm
env_vars:
- name: NODE_ENV
value: test
- name: CI
value: 'true'
jobs:
- name: Run lint
- name: yarn prettier
commands:
- cache restore client-node-modules-$SEMAPHORE_GIT_BRANCH-$(checksum yarn.lock),client-node-modules-$SEMAPHORE_GIT_BRANCH,client-node-modules-master
- yarn lint

- name: Formatting
task:
secrets:
- name: workos-npm
env_vars:
- name: NODE_ENV
value: test
- name: CI
value: 'true'
jobs:
- name: Run prettier
commands:
- cache restore client-node-modules-$SEMAPHORE_GIT_BRANCH-$(checksum yarn.lock),client-node-modules-$SEMAPHORE_GIT_BRANCH,client-node-modules-master
- yarn prettier

- name: Tests
task:
secrets:
- name: workos-npm
env_vars:
- name: NODE_ENV
value: test
- name: CI
value: 'true'
jobs:
- name: Run tests
- name: yarn lint
commands:
- yarn lint
- name: yarn test
commands:
- cache restore client-node-modules-$SEMAPHORE_GIT_BRANCH-$(checksum yarn.lock),client-node-modules-$SEMAPHORE_GIT_BRANCH,client-node-modules-master
- yarn test

- name: Build
task:
secrets:
- name: workos-npm
jobs:
- name: Run build
- name: yarn build
commands:
- cache restore client-node-modules-$SEMAPHORE_GIT_BRANCH-$(checksum yarn.lock),client-node-modules-$SEMAPHORE_GIT_BRANCH,client-node-modules-master
- yarn build

promotions:
Expand Down
14 changes: 14 additions & 0 deletions bin/restore-or-install
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

KEY="node-modules-$(checksum yarn.lock)"
cache restore $KEY

if [[ ! `ls -d ./node_modules 2>/dev/null` ]]; then
yarn install
cache store $KEY ./node_modules
fi

if [[ ! `ls -d ./node_modules/.bin 2>/dev/null` ]]; then
yarn install --check-files
cache store $KEY ./node_modules
fi

0 comments on commit 7c9efa0

Please sign in to comment.