Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: initialize this repo #11

Closed
wants to merge 51 commits into from
Closed
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
4e5c730
feat: add commitlint to ensure this repo's commit messages follow con…
gobengo Aug 26, 2020
943add0
ci: add .mergify.yml to opt-in to Mergify and re-enable matrix ci tes…
gobengo Aug 26, 2020
f44a182
docs: README describes mergify (#3)
gobengo Aug 26, 2020
d78f77a
docs: small README change just to test mergify (#6)
gobengo Aug 26, 2020
b8e874d
feat: add packages/bootstrap (from sdk:src/bootstrap) (#7)
gobengo Aug 26, 2020
d05cf86
fix: bootstrap package deps on @dfinity/agent via package.json (#8)
gobengo Aug 26, 2020
caaaf5d
wip publish
gobengo Aug 26, 2020
6ea331a
chore: wip publish
gobengo Aug 26, 2020
7432971
ci: add .github/workflows/npm-publish.yml
gobengo Aug 26, 2020
ecd700f
docs: touch readme
gobengo Aug 26, 2020
9f8f9c3
chore: release new versions
github-actions[bot] Aug 26, 2020
498f18f
chore: lerna.json version message includes the new version in commit …
gobengo Aug 26, 2020
a7afc15
docs: touch agent readme
gobengo Aug 26, 2020
94e00dd
chore: commit version v0.7.0-alpha.1
github-actions[bot] Aug 26, 2020
ed7e404
ci: npm-publish workflow does lerna version with --create-release github
gobengo Aug 26, 2020
91342df
chore: noop
gobengo Aug 26, 2020
d60aec7
chore: commit version v0.7.0-alpha.2
github-actions[bot] Aug 26, 2020
d6ef7f5
ci: dont prerelease on every master commit. Make it a manual action
gobengo Aug 26, 2020
394e1a2
Merge branch 'master' of github.com:dfinity-lab/agent-js
gobengo Aug 26, 2020
2576539
chore: commit version v0.7.0-alpha.3
github-actions[bot] Aug 26, 2020
a3e23ee
ci: add release github workflow
gobengo Aug 26, 2020
bbbb4c6
Merge branch 'master' of github.com:dfinity-lab/agent-js
gobengo Aug 26, 2020
2451734
chore: commit version v0.7.0-alpha.4
github-actions[bot] Aug 26, 2020
b2d7180
ci: single release workflow
gobengo Aug 27, 2020
c20f937
Merge branch 'master' of github.com:dfinity-lab/agent-js
gobengo Aug 27, 2020
85cdf51
fix: set up tsc project references so building bootstrap ensures agen…
gobengo Aug 28, 2020
0ca5269
ci: add npm prepare script to agent, bootstrap
gobengo Aug 28, 2020
e88fd2e
chore: remove lerna for now. we don't need it, and its hard to nix bu…
gobengo Aug 31, 2020
07906e8
fix: remove npm prepare script
gobengo Sep 1, 2020
2684726
chore: remove root package.json
gobengo Sep 1, 2020
a737f1b
chore: reintroduce top level package to appease napalm
gobengo Sep 1, 2020
c8a44f0
ci: bump
gobengo Sep 1, 2020
373eb2e
chore: clean up before code review
gobengo Sep 1, 2020
6da3e0a
fix: update package-lock.json
gobengo Sep 2, 2020
377b829
fix: add 0.0.0 version numbers to packages/*/package.json
gobengo Sep 2, 2020
38d47f8
Add bin/for-each-package util
gobengo Sep 2, 2020
f82191e
rm bin/import-*
gobengo Sep 8, 2020
65878ed
rm commitlint.config.js
gobengo Sep 8, 2020
7112caa
root package.json is now private and version=0.0.0
gobengo Sep 8, 2020
6ace900
LICENSE as Apache-2.0
gobengo Sep 8, 2020
c8773dc
reword packages/agent/README.md
gobengo Sep 8, 2020
7e22e2c
packages/bootstrap is npm private
gobengo Sep 8, 2020
4f8d171
remove unnecessary github workflows
gobengo Sep 8, 2020
6ab37fe
Describe bin/* scripts in README
gobengo Sep 8, 2020
f16d364
rm packages/bootstrap/README.html, which shouldnt be there
gobengo Sep 8, 2020
cca8d02
agent-js-devtools deps on webpack
gobengo Sep 9, 2020
2dfe72f
packages/bootstrap npm build script calls webpack
gobengo Sep 9, 2020
56c0946
Never use npx in npm scripts
gobengo Sep 9, 2020
c435842
rm package-lock.json in packages
gobengo Sep 9, 2020
5799552
move css-loader to dep of packages/bootstrap and update package-lock.…
gobengo Sep 9, 2020
2cb791e
Remove mentions of lerna from the README
gobengo Sep 9, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/commitlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Lint Commit Messages
on:
- pull_request
- push

jobs:
commitlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v2
21 changes: 21 additions & 0 deletions .github/workflows/conventional-commits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Check PR title
on:
pull_request:
types:
- opened
- reopened
- edited
- synchronize

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: hansl/conventional-pr-title-action@v2.2.0
with:
success-state: Title follows the specification.
failure-state: Title does not follow the specification.
context-name: conventional-pr-title
preset: conventional-changelog-angular@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ jobs:
# The test beforehand won't do it if the relevant subpackge's ndoe_modules were already fetched.
run: "[ -d packages/agent/node_modules ] || npm run postinstall"
- run: npm run build --if-present
- run: ls node_modules
- run: ls node_modules/.bin
- run: ls packages
- run: ls packages/agent
# - run: (cd packages/)
- run: npm test
env:
CI: true
39 changes: 39 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Release
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove, create an issue for this and we'll do it when we're ready for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#15


on:
workflow_dispatch:
inputs:
canary:
default: 'true'

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: git config identity
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/$GITHUB_REPOSITORY
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: test npm auth
run: npm whoami
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# canary
- if: ${{ github.event.inputs.canary }}
run: npx lerna publish --canary --yes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# not canary: full release
- if: ${{ ! github.event.inputs.canary }}
run: npx lerna publish --yes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29 changes: 29 additions & 0 deletions .mergify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
pull_request_rules:
- name: Automatic merge
conditions:
- "#approved-reviews-by>=1"
- "#changes-requested-reviews-by=0"
- status-success=conventional-pr-title
- label=automerge-squash
actions:
merge:
method: squash
strict: smart
commit_message: title+body
delete_head_branch: {}

- name: Clean up automerge tags
conditions:
- closed
actions:
label:
remove:
- automerge-squash

- name: Auto-approve auto-PRs
conditions:
- author=dfinity-bot
actions:
review:
type: APPROVE
message: This bot trusts that bot
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

Use an Agent to interact with the Internet Computer from your JavaScript program.

This source code repository contains multiple npm packages, and [lerna](https://lerna.js.org/) provides tools for managing the monorepo. Currently we use lerna in ['fixed' mode](https://github.com/lerna/lerna#fixedlocked-mode-default), which means all packages are the same version. This may change in the future.
This source code repository contains multiple npm packages, but it's primary export is at `./packages/agent`.

## Development

### Getting Started

1. Clone the git repository.
2. Run `npm install`
* The npm postinstall script should automatically call `lerna bootstrap`, which will install/link all subpackages.

After that, you probably want to dive into a specific package in [./packages](./packages).

Expand Down Expand Up @@ -40,6 +39,15 @@ npx lerna add dependency-name --scope='@dfinity/agent'

GitHub Actions for this repo are configured in [./.github/workflows](./.github/workflows).

* [push.yml](./.github/workflows/push.yml) - For every git push, do build, test of all packages.
* [nodejs-ci.yml](./.github/workflows/nodejs-ci.yml) - For every git push, do a build, test of all packages.
* [commitlint.yml](./.github/workflows/commitlint.yml) - Run [commitlint](https://commitlint.js.org/#/) on every git commit message.

When developing these configuration files, you may test with [nektos/act](https://github.com/nektos/act). Please do your best to keep all workflows working with act.

### Master Branch Conventions and Mergify

All commits in the master branch should come from squashed GitHub Pull Requests, and those commit messages should follow the [conventionalcommits.org](https://conventionalcommits.org) syntax.

Mergify can take care of enforcing all of this. Just add the `automerge-squash` label to each Pull Request that Mergify should merge. This policy is configured via [./.mergify.yml](./.mergify).


When developing these configuration files, you may test with [nektos/act](https://github.com/nektos/act).
13 changes: 13 additions & 0 deletions bin/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

# exit on error
set -e

for package in ./packages/*
do
(
echo "building package: $package"
cd "$package"
npm run build --if-present
)
done
34 changes: 34 additions & 0 deletions bin/for-each-package
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh

# exit on error
set -e

function help {
msg="$(cat <<-EOF
This repository is the new home for the @dfinity/agent npm package.
This script will take a path to its old home in the sdk, then copy it here to ./packages/agent w/ any transformations required as part of the 'move'.

Usage:
./import-agent-from ~/dfinity/sdk/src/agent/javascript

EOF)"
echo "$msg"
}

function main {
args=("$@")

for package in ./packages/*
do
(
echo
echo "package: $package"
echo "running: "${args[*]}""
echo
${args[*]}
echo
)
done
}

main $@
32 changes: 32 additions & 0 deletions bin/import-agent-from
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env sh

function help {
msg="$(cat <<-EOF
This repository is the new home for the @dfinity/agent npm package.
This script will take a path to its old home in the sdk, then copy it here to ./packages/agent w/ any transformations required as part of the 'move'.

Usage:
./import-agent-from ~/dfinity/sdk/src/agent/javascript

EOF)"
echo "$msg"
}

function main {
agent_target="$(dirname $0)"/../packages/agent
agent_src="$1"
if [[ -z "$agent_src" ]]; then
help
echo
echo "Error: Provide a path to the sdk agent directory to import from there"
exit 1
fi
# Warning
rm -rf "$agent_target"
cp -a "$agent_src" "$agent_target"
# Remove files we dont need
find "$agent_target" -name '*INTERNAL*' | xargs rm
find "$agent_target" -name '*.nix' | xargs rm
}

main $@
36 changes: 36 additions & 0 deletions bin/import-bootstrap-from
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env sh

function help {
msg="$(cat <<-EOF
This repository is the new home for the @dfinity/bootstrap npm package.
This script will take a path to its old home in the sdk, then copy it here to ./packages/bootstrap w/ any transformations required as part of the 'move'.

Usage:
./import-bootstrap-from ~/dfinity/sdk/src/bootstrap

EOF)"
echo "$msg"
}

function main {
bootstrap_target="$(dirname $0)"/../packages/bootstrap
bootstrap_src="$1"
if [[ -z "$bootstrap_src" ]]; then
help
echo
echo "Error: Provide a path to the sdk bootstrap directory to import from there"
exit 1
fi

# Warning
rm -rf "$bootstrap_target"

cp -a "$bootstrap_src" "$bootstrap_target"

# Remove files we dont want
find "$bootstrap_target" -name '*INTERNAL*' | xargs rm
find "$bootstrap_target" -name '*.nix' | xargs rm
echo "test.todo('@dfinity/bootstrap has tests');" > "$bootstrap_target"/src/index.test.ts
}

main $@
16 changes: 16 additions & 0 deletions bin/npm-postinstall
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

# exit on error
set -e

devtools_node_modules="packages/agent-js-devtools/node_modules"

# Copy npm devtools into ./node_modules.
# Because npm resolves tools in ancestor dirs' node_modules too,
# this should make common devtools like jest/tsc be found when
# run from npm runscripts inside ./packages/*/
if test -d "$devtools_node_modules"; then
cp -R "$devtools_node_modules"/. node_modules/
else
echo "warn: npm-postinstall did not find dir $devtools_node_modules"
fi
13 changes: 13 additions & 0 deletions bin/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

# exit on error
set -e

for package in ./packages/*
do
(
echo "testing package: $package"
cd "$package"
npm test
)
done
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {extends: ['@commitlint/config-conventional']}
6 changes: 0 additions & 6 deletions lerna.json

This file was deleted.

Loading