Skip to content

Commit

Permalink
chore: yarn workspaces, release please (#290)
Browse files Browse the repository at this point in the history
* add basic config

* update scripts

* update workflows

* fix workflow

* fix release please

* more fixes

* fix cd

* add dependabot and semantic pr

* Update release-please configuration

* Move cloudflare deploy into cd workflow

* Remove old release workflow

* Revert yarn.lock changes

Co-authored-by: Cayman <caymannava@gmail.com>
  • Loading branch information
mpetrunic and wemeetagain authored Jan 6, 2023
1 parent 3e81068 commit 7bd63c6
Show file tree
Hide file tree
Showing 27 changed files with 14,316 additions and 30,261 deletions.
11 changes: 11 additions & 0 deletions .github/.dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: "yarn"
schedule:
interval: daily
requiredLabels:
- dependencies
commit-message:
prefix: fix
prefix-development: chore
include: scope
8 changes: 5 additions & 3 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ jobs:
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: yarn
node-version: 18
- run: yarn && yarn build
- run: corepack enable
- run: yarn --immutable && yarn build

- name: Run benchmarks
run: yarn benchmark
Expand Down
67 changes: 67 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Release

on:
workflow_run:
workflows: [ Tests ]
branches: [master]
types:
- completed

jobs:
maybe-release:
name: release
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success'
steps:

- uses: google-github-actions/release-please-action@v3
id: release
with:
command: manifest
token: ${{secrets.GITHUB_TOKEN}}
default-branch: master
release-type: node
monorepo-tags: true
changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"chore","section":"Miscellaneous","hidden":true}]'

- uses: actions/checkout@v3
if: ${{ steps.release.outputs.releases_created }}

- uses: actions/setup-node@v3
with:
cache: 'yarn'
node-version: 16
registry-url: 'https://registry.npmjs.org'
if: ${{ steps.release.outputs.releases_created }}

- run: corepack enable

- run: yarn install --immutable
if: ${{ steps.release.outputs.releases_created }}

- run: git config user.email $(git --no-pager show -s --format='%ae' HEAD)
if: ${{ steps.release.outputs.releases_created }}
- run: git config user.name $(git --no-pager show -s --format='%an' HEAD)
if: ${{ steps.release.outputs.releases_created }}

- run: yarn build
if: ${{ steps.release.outputs.releases_created }}

- env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
if: ${{ steps.release.outputs.releases_created }}
run: |
echo npmAuthToken: "$NODE_AUTH_TOKEN" >> ./.yarnrc.yml
- run: yarn workspaces foreach -v --exclude root --exclude simpleserialize.com --no-private npm publish --tolerate-republish --access public
if: ${{ steps.release.outputs.releases_created }}


- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: simpleserialize
directory: ./packages/simpleserialize.com/dist
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
25 changes: 0 additions & 25 deletions .github/workflows/cf-deploy.yaml

This file was deleted.

50 changes: 0 additions & 50 deletions .github/workflows/release.yml

This file was deleted.

23 changes: 23 additions & 0 deletions .github/workflows/semantic-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: "Semantic PR"

on:
pull_request_target:
types:
- opened
- edited
- synchronize

jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
types: |
fix
feat
chore
revert
22 changes: 12 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ jobs:
matrix:
node: [16, 18]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{matrix.node}}
cache: yarn
- run: corepack enable
- name: Bootstrap
run: yarn
run: yarn --immutable
- name: Build
run: yarn build
- name: Check types
Expand All @@ -40,23 +42,23 @@ jobs:
# Otherwise just doing `yarn test:spec` you can't tell which specific suite failed
# many of the suites have identical names for minimal and mainnet
- name: Spec tests general
run: ../../node_modules/.bin/mocha test/spec/generic/index.test.ts
run: yarn run -T mocha test/spec/generic/index.test.ts
working-directory: packages/ssz
- name: Spec tests phase0-minimal
run: LODESTAR_PRESET=minimal LODESTAR_FORK=phase0 ../../node_modules/.bin/mocha test/spec/ssz_static.test.ts
run: LODESTAR_PRESET=minimal LODESTAR_FORK=phase0 yarn run -T mocha test/spec/ssz_static.test.ts
working-directory: packages/ssz
- name: Spec tests phase0-mainnet
run: LODESTAR_PRESET=mainnet LODESTAR_FORK=phase0 ../../node_modules/.bin/mocha test/spec/ssz_static.test.ts
run: LODESTAR_PRESET=mainnet LODESTAR_FORK=phase0 yarn run -T mocha test/spec/ssz_static.test.ts
working-directory: packages/ssz
- name: Spec tests altair-minimal
run: LODESTAR_PRESET=minimal LODESTAR_FORK=altair ../../node_modules/.bin/mocha test/spec/ssz_static.test.ts
run: LODESTAR_PRESET=minimal LODESTAR_FORK=altair yarn run -T mocha test/spec/ssz_static.test.ts
working-directory: packages/ssz
- name: Spec tests altair-mainnet
run: LODESTAR_PRESET=mainnet LODESTAR_FORK=altair ../../node_modules/.bin/mocha test/spec/ssz_static.test.ts
run: LODESTAR_PRESET=mainnet LODESTAR_FORK=altair yarn run -T mocha test/spec/ssz_static.test.ts
working-directory: packages/ssz
- name: Spec tests bellatrix-minimal
run: LODESTAR_PRESET=minimal LODESTAR_FORK=bellatrix ../../node_modules/.bin/mocha test/spec/ssz_static.test.ts
run: LODESTAR_PRESET=minimal LODESTAR_FORK=bellatrix yarn run -T mocha test/spec/ssz_static.test.ts
working-directory: packages/ssz
- name: Spec tests bellatrix-mainnet
run: LODESTAR_PRESET=mainnet LODESTAR_FORK=bellatrix ../../node_modules/.bin/mocha test/spec/ssz_static.test.ts
run: LODESTAR_PRESET=mainnet LODESTAR_FORK=bellatrix yarn run -T mocha test/spec/ssz_static.test.ts
working-directory: packages/ssz
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,10 @@ packages/ssz/spec-tests

benchmark_data/
.failedTest.txt

node_modules
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/sdks
!.yarn/versions
6 changes: 6 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"packages/as-sha256": "0.3.1",
"packages/persistent-merkle-tree": "0.4.2",
"packages/persistent-ts": "0.19.1",
"packages/ssz": "0.10.0"
}
9 changes: 9 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-engines.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* eslint-disable */
//prettier-ignore
module.exports = {
name: "@yarnpkg/plugin-engines",
factory: function (require) {
var plugin=(()=>{var P=Object.create,f=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,Y=Object.prototype.hasOwnProperty;var b=n=>f(n,"__esModule",{value:!0});var i=n=>{if(typeof require!="undefined")return require(n);throw new Error('Dynamic require of "'+n+'" is not supported')};var T=(n,e)=>{for(var r in e)f(n,r,{get:e[r],enumerable:!0})},V=(n,e,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of N(e))!Y.call(n,t)&&t!=="default"&&f(n,t,{get:()=>e[t],enumerable:!(r=R(e,t))||r.enumerable});return n},s=n=>V(b(f(n!=null?P(j(n)):{},"default",n&&n.__esModule&&"default"in n?{get:()=>n.default,enumerable:!0}:{value:n,enumerable:!0})),n);var U={};T(U,{default:()=>q});var o=s(i("@yarnpkg/core")),c;(function(r){r.Yarn="Yarn",r.Console="Console"})(c||(c={}));var h=class{constructor(e){this.throwWrongEngineError=(e,r)=>{let t=this.formatErrorMessage(e,r);this.throwError(t)};this.throwError=e=>{switch(this.errorReporter){case c.Yarn:this.reportYarnError(e);break;case c.Console:default:this.reportConsoleError(e);break}};this.reportYarnError=e=>{throw new o.ReportError(o.MessageName.UNNAMED,e)};this.reportConsoleError=e=>{console.error(e),process.exit(1)};this.formatErrorMessage=(e,r)=>{let{configuration:t}=this.project,p=o.formatUtils.applyStyle(t,o.formatUtils.pretty(t,this.engine,"green"),2),g=o.formatUtils.pretty(t,e,"cyan"),d=o.formatUtils.pretty(t,r,"cyan"),w=`The current ${p} version ${g} does not satisfy the required version ${d}.`;return o.formatUtils.pretty(t,w,"red")};this.project=e.project,this.errorReporter=e.errorReporter}};var m=s(i("fs")),y=s(i("path")),l=s(i("semver")),k=s(i("@yarnpkg/fslib")),a=s(i("@yarnpkg/core"));var v=class extends h{constructor(){super(...arguments);this.resolveNvmRequiredVersion=()=>{let{configuration:e,cwd:r}=this.project,t=(0,y.resolve)(k.npath.fromPortablePath(r),".nvmrc"),p=a.formatUtils.applyStyle(e,a.formatUtils.pretty(e,this.engine,"green"),2);if(!(0,m.existsSync)(t)){this.throwError(a.formatUtils.pretty(e,`Unable to verify the ${p} version. The .nvmrc file does not exist.`,"red"));return}let g=(0,m.readFileSync)(t,"utf-8").trim();if((0,l.validRange)(g))return g;let d=a.formatUtils.pretty(e,".nvmrc","yellow");this.throwError(a.formatUtils.pretty(e,`Unable to verify the ${p} version. The ${d} file contains an invalid semver range.`,"red"))}}get engine(){return"Node"}verifyEngine(e){let r=e.node;r!=null&&(r===".nvmrc"&&(r=this.resolveNvmRequiredVersion()),(0,l.satisfies)(process.version,r,{includePrerelease:!0})||this.throwWrongEngineError(process.version.replace(/^v/i,""),r.replace(/^v/i,"")))}};var x=s(i("semver")),E=s(i("@yarnpkg/core"));var u=class extends h{get engine(){return"Yarn"}verifyEngine(e){let r=e.yarn;r!=null&&((0,x.satisfies)(E.YarnVersion,r,{includePrerelease:!0})||this.throwWrongEngineError(E.YarnVersion,r))}};var C=n=>e=>{if(process.env.PLUGIN_YARN_ENGINES_DISABLE!=null)return;let{engines:r={}}=e.getWorkspaceByCwd(e.cwd).manifest.raw,t={project:e,errorReporter:n};[new v(t),new u(t)].forEach(g=>g.verifyEngine(r))},S={hooks:{validateProject:C(c.Yarn),setupScriptEnvironment:C(c.Console)}},q=S;return U;})();
return plugin;
}
};
Loading

0 comments on commit 7bd63c6

Please sign in to comment.