Skip to content

Commit

Permalink
Add test dapp workflow template (Agoric#1897)
Browse files Browse the repository at this point in the history
* chore: add a workflow template for testing a dapp

* chore: use test-dapp template in test-dapp-encouragement

* chore: standardize documentation workflow

* chore: assume that dapps should have a main branch, not master

* chore: address PR comments

* chore: fix comment
  • Loading branch information
katelynsills authored Oct 22, 2020
1 parent 48682e2 commit 18c0314
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 36 deletions.
82 changes: 82 additions & 0 deletions .github/workflow-templates/test-dapp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Test Dapp

# run CI on pushes to master, and on all PRs (even the ones that target other
# branches)

on:
push:
branches: [ $default-branch ]
pull_request:

jobs:
test-dapp:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ['14.x']

steps:

- name: Checkout agoric-sdk
uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: cache node modules
uses: actions/cache@v1
with:
path: ~/.cache/yarn
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
# Select a branch on dapp to test against by adding text to the body of the
# pull request. For example: #dapp-encouragement-branch: zoe-release-0.7.0
# The default is 'main'
- name: Get the appropriate dapp branch
id: get-branch
uses: actions/[email protected]
with:
result-encoding: string
script: |
let branch = 'main';
if (context.payload.pull_request) {
const { body } = context.payload.pull_request;
const regex = /.*\#[[INSERT_DAPP_NAME]]-branch:\s+(\S+)/;
const result = regex.exec(body);
if (result) {
branch = result[1];
}
}
console.log(branch);
return branch;
- name: yarn install
run: yarn install
# 'yarn build' loops over all workspaces
- name: yarn build
run: yarn build
- name: yarn link
run: |
yarn link-cli ~/bin/agoric
echo "::add-path::/home/runner/bin"
- name: Check out dapp
uses: actions/checkout@v2
with:
repository: Agoric/[[INSERT_DAPP_NAME]]
path: dapp
ref: ${{steps.get-branch.outputs.result}}

- name: Agoric install in dapp
run: agoric install
working-directory: ./dapp

- name: yarn build in dapp
run: yarn build
working-directory: ./dapp

- name: yarn test in dapp
run: yarn test
working-directory: ./dapp
37 changes: 18 additions & 19 deletions .github/workflows/test-dapp-encouragement.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ name: Test Dapp Encouragement
# branches)

on:
push:
branches: [master]
pull_request:
push:
branches: [ $default-branch ]
pull_request:

jobs:
dapp-encouragement:
test-dapp:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ['12.14.1', '12.x', '14.x']
node-version: ['14.x']

steps:

- name: Checkout agoric-sdk
Expand All @@ -31,16 +32,16 @@ jobs:
restore-keys: |
${{ runner.os }}-yarn-
# Select a branch on dapp-encouragement to test against by adding text to the body of the
# Select a branch on dapp to test against by adding text to the body of the
# pull request. For example: #dapp-encouragement-branch: zoe-release-0.7.0
# The default is 'master'
- name: Get the appropriate dapp-encouragement branch
# The default is 'main'
- name: Get the appropriate dapp branch
id: get-branch
uses: actions/[email protected]
with:
result-encoding: string
script: |
let branch = 'master';
let branch = 'main';
if (context.payload.pull_request) {
const { body } = context.payload.pull_request;
const regex = /.*\#dapp-encouragement-branch:\s+(\S+)/;
Expand All @@ -54,8 +55,6 @@ jobs:
- name: yarn install
run: yarn install
- name: check dependencies
run: yarn check-dependencies
# 'yarn build' loops over all workspaces
- name: yarn build
run: yarn build
Expand All @@ -64,21 +63,21 @@ jobs:
yarn link-cli ~/bin/agoric
echo "/home/runner/bin" >> $GITHUB_PATH
- name: Check out dapp-encouragement
- name: Check out dapp
uses: actions/checkout@v2
with:
repository: Agoric/dapp-encouragement
path: dapp-encouragement
path: dapp
ref: ${{steps.get-branch.outputs.result}}

- name: Agoric install in dapp-encouragement
- name: Agoric install in dapp
run: agoric install
working-directory: ./dapp-encouragement
working-directory: ./dapp

- name: yarn build in dapp-encouragement
- name: yarn build in dapp
run: yarn build
working-directory: ./dapp-encouragement
working-directory: ./dapp

- name: yarn test in dapp-encouragement
- name: yarn test in dapp
run: yarn test
working-directory: ./dapp-encouragement
working-directory: ./dapp
37 changes: 20 additions & 17 deletions .github/workflows/test-documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ name: Test Documentation
# branches)

on:
push:
branches: [master]
pull_request:
push:
branches: [ $default-branch ]
pull_request:

jobs:
documentation:
test-dapp:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ['14.x']

steps:

- name: Checkout agoric-sdk
Expand All @@ -31,16 +32,16 @@ jobs:
restore-keys: |
${{ runner.os }}-yarn-
# Select a branch on documentation to test against by adding text to the body of the
# pull request. For example: #documentation-branch: zoe-release-0.7.0
# The default is 'master'
- name: Get the appropriate documentation branch
# Select a branch on dapp to test against by adding text to the body of the
# pull request. For example: #dapp-encouragement-branch: zoe-release-0.7.0
# The default is 'main'
- name: Get the appropriate dapp branch
id: get-branch
uses: actions/[email protected]
with:
result-encoding: string
script: |
let branch = 'master';
let branch = 'main';
if (context.payload.pull_request) {
const { body } = context.payload.pull_request;
const regex = /.*\#documentation-branch:\s+(\S+)/;
Expand All @@ -54,8 +55,6 @@ jobs:
- name: yarn install
run: yarn install
- name: check dependencies
run: yarn check-dependencies
# 'yarn build' loops over all workspaces
- name: yarn build
run: yarn build
Expand All @@ -64,17 +63,21 @@ jobs:
yarn link-cli ~/bin/agoric
echo "/home/runner/bin" >> $GITHUB_PATH
- name: Check out documentation
- name: Check out dapp
uses: actions/checkout@v2
with:
repository: Agoric/documentation
path: documentation
path: dapp
ref: ${{steps.get-branch.outputs.result}}

- name: Agoric install in documentation
- name: Agoric install in dapp
run: agoric install
working-directory: ./documentation
working-directory: ./dapp

- name: yarn build in dapp
run: yarn build
working-directory: ./dapp

- name: yarn test in documentation
- name: yarn test in dapp
run: yarn test
working-directory: ./documentation
working-directory: ./dapp

0 comments on commit 18c0314

Please sign in to comment.