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

New git branches setup #1262

Closed
wants to merge 74 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
bdedad8
add dev branch to auto merge
goastler Jun 3, 2024
66552cc
make clippy run on new branch setup
goastler Jun 3, 2024
965609a
remove version checker workflow
goastler Jun 3, 2024
09ab63b
add dev and release branch triggers to consistent workflow name checker
goastler Jun 3, 2024
fe52011
Delete create_diagram.yml
goastler Jun 3, 2024
3ff530d
add dev and release branch triggers to lint workflow
goastler Jun 3, 2024
a8d5a28
add release and dev branch triggers to provider_image workflow
goastler Jun 3, 2024
ae8d8f9
remove release drafter
goastler Jun 3, 2024
e13f1bb
add dev and release branches to rustfmt workflow
goastler Jun 3, 2024
ef466e6
add dev and release branches to protocol test workflow
goastler Jun 3, 2024
dffd3b6
add dev and release branches triggers to tests workflow
goastler Jun 3, 2024
deed023
add dev and release branch triggers to webpack bundling workflow
goastler Jun 3, 2024
308df33
switch cache creation to be post pr to dev
goastler Jun 3, 2024
1eef4c0
rename post_pr workflow to cache
goastler Jun 3, 2024
0aadf03
Update cache.yml
goastler Jun 3, 2024
5215a52
publish workflow
goastler Jun 3, 2024
270e721
Update cache.yml
goastler Jun 13, 2024
13ce8d2
Merge branch 'main' into git-setup
goastler Jul 1, 2024
19dcb44
fix contract js/rust version check workflow
goastler Jul 1, 2024
6d97672
install concurrently and cypress as workspace deps
goastler Jul 1, 2024
7b1b92b
fix cypress workflow trigger
goastler Jul 1, 2024
52df9ae
fix cypress workflow branch triggers
goastler Jul 1, 2024
ca30c6d
fix rust file triggers
goastler Jul 1, 2024
0c43736
move webpack bundling check to tests workflow
goastler Jul 1, 2024
1be682a
remove typechain version check
goastler Jul 1, 2024
16474dc
rename workflows
goastler Jul 1, 2024
b370557
make the github actions cache include the branch name
goastler Jul 1, 2024
88e5c18
publish on push to main
goastler Jul 1, 2024
178d62f
add js bundle test step
goastler Jul 1, 2024
e7a690b
workflow for ensuring all versions move in lockstep
goastler Jul 2, 2024
e719b9d
blurb for each workflow
goastler Jul 2, 2024
e77616c
dockerhub login check for before a release
goastler Jul 2, 2024
f08361d
rename publish to release
goastler Jul 2, 2024
36e8425
remove typedoc step
goastler Jul 2, 2024
0bb289b
standardise step ids in release workflow
goastler Jul 2, 2024
d1c6e5a
dummy version bump
goastler Jul 2, 2024
95acebe
Delete dockerhub_login.yml
goastler Jul 2, 2024
a88de41
release version check
goastler Jul 2, 2024
fdcf40e
workflow to check for valid version bumps
goastler Jul 2, 2024
50df1c1
auto merge all prs
goastler Jul 2, 2024
424a5ac
check consistent workflow names on all prs
goastler Jul 2, 2024
93412cf
branch system docs
goastler Jul 2, 2024
adf4874
check contract version on prs to main,dev,release/*
goastler Jul 2, 2024
f42b3b7
add workflow_dispatch to all relevant workflows
goastler Jul 2, 2024
c787594
make auto merge only run on non-draft prs
goastler Jul 2, 2024
6506cee
check versions on all branches
goastler Jul 2, 2024
f3decd3
make release run on push to main
goastler Jul 2, 2024
99ac204
tag pushes to main
goastler Jul 2, 2024
11fa7f2
rename version check workflow
goastler Jul 2, 2024
0f8d3d0
remove fetch all history and branches from clone
goastler Jul 2, 2024
fcd9ee2
fix docker js server version issue
goastler Jul 2, 2024
d78a1dd
fix bump workflow to bump all package.json files and Cargo.tomls
goastler Jul 2, 2024
dda17e0
fix package.json version writing in bump workflow
goastler Jul 2, 2024
ddac123
rename step
goastler Jul 3, 2024
161155e
Merge branch 'main' into git-setup
goastler Jul 3, 2024
8f07ff2
make auto merge cancellable
goastler Jul 3, 2024
abced5d
make deploy ahve a single notification of pass/fail
goastler Jul 3, 2024
d1e0f12
debug info
goastler Jul 3, 2024
e7f1068
fix cache workflow name
goastler Jul 3, 2024
72e5911
don't use cache in bump version workflow, not needed
goastler Jul 3, 2024
2eb1d6a
move buildx to top of workflow
goastler Jul 3, 2024
490323e
move the cli building to before publishing images in deploy workflow
goastler Jul 3, 2024
eec7a05
tag warning
goastler Jul 3, 2024
9c29b53
remove filters for tests, test more often
goastler Jul 3, 2024
1d5b4f5
add workflow dispatch to deploy workflow
goastler Jul 3, 2024
f3731ba
add bash error catching
goastler Jul 3, 2024
f80f157
Create consistent_engine_node.yml
goastler Jul 3, 2024
b93648f
Create consistent_engine_npm.yml
goastler Jul 3, 2024
bb2c59e
Create consistent_nvmrc.yml
goastler Jul 3, 2024
be8b86a
cache docs
goastler Jul 3, 2024
95483ad
event workflows for main and dev
goastler Jul 3, 2024
84d2d65
change event setup
goastler Jul 3, 2024
d7f2d84
don't run unless non-draft pr
goastler Jul 3, 2024
2bc4ad9
combine protocol clippy and rustfmt into single lint workflow
goastler Jul 3, 2024
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
30 changes: 30 additions & 0 deletions .github/branches.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

main branch
- contains latest stable release

dev branch
- latest dev version
- branch off this to make feature X, then PR back in

1 branch per release (aka release branches)
- note that these are for preparing a release, not making a deployment
- these are created by branching off the dev branch, e.g. release/0.3.45
- do all the testing here, e.g. staging, etc
- when sufficiently tested, merge branch into main

on merge of release/x.y.z into main
- after merging to main, create a tag for that version on main branch
- delete the release branch - we don't need it anymore. Releases should be managed via tags due to immutability (e.g. a branch could be pushed to in the future, whcih wouldn't make sense for a release of 0.3.45 to be mutated after being released to npm, dockerhub, etc, whereas a tag is just as-is, can't be updated)
- deploy to dockerhub, npm, etc
- merge main into dev branch to bring across version bumps for the release (and any other release based changes, e.g. changelog, etc)

pros:
- main contains the latest stable code, so easy to work with for newcomers (we don't have this currently as main is the bleeding edge code)
- merging a release branch into main is a great place to do the tagging of releases (e.g. release 0.3.45), i.e. main just becomes a log of release/a.b.c then release/d.e.f, etc, etc
- staging in the release branch
- release branches allow us a gap to prep a release, i.e. build it, make a contract / staging env, run some automated or manual tests, etc. It's essentially saying "take dev branch in this state and prep a release". The prep can be tweaking the dev code if need be to making it release worthy, but only changes required for releasing, we shouldn't be doing dev on release branches
- hotfixes are easy, branch off main, make the fix, do a release branch, pr back into main, then the hotfix will get pushed to dev too

cons:
- more branches so more discipline needed by us to not f it up (though I think the above plan is pretty simple, we can do it)
- two big branches (main and dev) compared to our current process of 1
5 changes: 0 additions & 5 deletions .github/release-drafter.yml

This file was deleted.

7 changes: 0 additions & 7 deletions .github/weekly-digest.yml

This file was deleted.

12 changes: 10 additions & 2 deletions .github/workflows/auto_merge.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
# Merge a PR automatically when opened or reopened

name: auto_merge

on:
pull_request:
branches: [main]
types:
- opened
- reopened

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
auto_merge:
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
steps:
- name: Print contexts
env:
Expand Down Expand Up @@ -53,7 +59,9 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- run: npm i -g npm@$(cat package.json | jq -r .engines.npm)

- name: Install
run: npm i -g npm@$(cat package.json | jq -r .engines.npm)

- name: Enable auto-merge on PR
env:
Expand Down
56 changes: 16 additions & 40 deletions .github/workflows/bump_version.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Workflow which bumps the version of all packages in the repo

name: bump_version

on:
Expand Down Expand Up @@ -57,51 +59,25 @@ jobs:

- uses: actions/checkout@v3

- run: mkdir -p protocol/cargo-cache
- run: mkdir -p protocol/target
- run: mkdir -p node_modules
- run: mkdir -p ~/.cache/Cypress

- name: Restore cache
uses: actions/cache/restore@v3
with:
path: |
protocol/cargo-cache
protocol/target
node_modules
~/.cache/Cypress
# note that restoring a cache in github is a pain. The trailing '-' matches any string after the '-', therefore 'abc-' would match a cache named 'abc-1234' or 'abc-5678', etc.
# the problem is 'abc-' will not match a cache named 'abc'! So if you're using wildcard cache name selectors like this, you need a field that changes as the suffix to become the wildcard
# here we're setting the key to an unused cache key so it falls back to the wildcard selector in `restore-keys`
key: some-unused-cache-key
restore-keys: |
project-cache-${{ runner.os }}-${{ runner.arch }}-

- run: ls -la ~/.cache/Cypress || true
- run: ls -la protocol/cargo-cache || true
- run: ls -la protocol/target/ink || true
- run: ls -la node_modules || true

- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- run: npm i -g npm@$(cat package.json | jq -r .engines.npm)

- run: npm ci

- run: npm run build -w @prosopo/scripts
- run: npm run build -w @prosopo/protocol-dev

- name: Bump version
env:
GITHUB_TOKEN: ${{ secrets.PROSOPONATOR_PAT }}
run: |
set -euxo pipefail # stop on errors, print commands, fail on pipe fails

# make a new branch for the version changes
git switch -c bump-version-${{ github.event.inputs.version }}

# make the version changes
npm run version ${{ github.event.inputs.version }}

git switch -c release/${{ github.event.inputs.version }}

# find all package.json files, recursively
pkgJsons=$(find . -name package.json -prune -not -path '*/node_modules/*' -not -path '*/.next/*')
# replace the version in all package.json files
xargs -I % sh -c "cat % | jq '.version = \"${{ github.event.inputs.version }}\"' > %.new && mv %.new %" <<< "$pkgJsons"

# find all Cargo.toml files
cargoTomls=$(find . -name Cargo.toml -prune -not -path '*/protocol/cargo-cache/*')
# replace the first version line in all Cargo.toml files
xargs -I % sh -c "sed -i '0,/version =/s/version =.*/version = \"${{ github.event.inputs.version }}\"/' %" <<< "$cargoTomls"

# rebuild typechain
npm run build:typechain

Expand Down
19 changes: 10 additions & 9 deletions .github/workflows/post_pr.yml → .github/workflows/cache.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
name: post_pr
# Build a cache of build artifacts after PRs to speed up subsequent builds

name: cache

# on push to main, or manually triggered
# we do this because any branch can use caches built on main, whereas caches built on other branches are only available to that branch and its children
on:
push:
branches:
- 'main'
branches: [main, dev]
workflow_dispatch:

concurrency:
Expand Down Expand Up @@ -60,6 +59,7 @@ jobs:

- uses: actions/checkout@v3

# make cache dirs
- run: mkdir -p protocol/cargo-cache
- run: mkdir -p protocol/target
- run: mkdir -p node_modules
Expand Down Expand Up @@ -103,20 +103,21 @@ jobs:
protocol/target
node_modules
~/.cache/Cypress
key: project-cache-${{ runner.os }}-${{ runner.arch }}-${{ github.run_id }}-${{ github.run_attempt }}
key: project-cache-${{ github.event.pull_request.head.ref || github.ref }}-${{ runner.os }}-${{ runner.arch }}-${{ github.run_id }}-${{ github.run_attempt }}

# remove all but the latest cache, leaving only the cache we just saved
- name: Cleanup caches
if: always()
run: |
set -euxo pipefail # stop on errors, print commands, fail on pipe fails

set +e; gh extension install actions/gh-actions-cache; set -e
REPO=${{ github.repository }}
echo "Fetching list of cache key"
cacheKeys=$(gh actions-cache list --sort created-at --order desc --limit 100 -R $REPO --key project-cache-${{ runner.os }}-${{ runner.arch }}- | cut -f 1 | tail -n +3)
cacheKeys=$(gh actions-cache list --sort created-at --order desc --limit 100 -R ${{ github.repository }} --key project-cache-${{ github.event.pull_request.head.ref || github.ref }}-${{ runner.os }}-${{ runner.arch }}- | cut -f 1 | tail -n +3)
echo caches to be removed:
echo ${cacheKeys}
set +e
for cacheKey in $cacheKeys
do
gh actions-cache delete $cacheKey -R $REPO --confirm
gh actions-cache delete $cacheKey -R ${{ github.repository }} --confirm
done
99 changes: 99 additions & 0 deletions .github/workflows/check_version_bump.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Check the version has been bumped before releasing

name: check_version_bump

on:
pull_request:
branches: [main]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
check:
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
steps:
- name: Print contexts
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
ENV_CONTEXT: ${{ toJson(env) }}
VARS_CONTEXT: ${{ toJson(vars) }}
JOB_CONTEXT: ${{ toJson(job) }}
STEPS_CONTEXT: ${{ toJson(steps) }}
RUNNER_CONTEXT: ${{ toJson(runner) }}
SECRETS_CONTEXT: ${{ toJson(secrets) }}
STRATEGY_CONTEXT: ${{ toJson(strategy) }}
MATRIX_CONTEXT: ${{ toJson(matrix) }}
NEEDS_CONTEXT: ${{ toJson(needs) }}
INPUTS_CONTEXT: ${{ toJson(inputs) }}
run: |
echo "******************************"
echo "github:" "$GITHUB_CONTEXT"
echo "******************************"
echo "env:" "$ENV_CONTEXT"
echo "******************************"
echo "vars:" "$VARS_CONTEXT"
echo "******************************"
echo "job:" "$JOB_CONTEXT"
echo "******************************"
echo "steps:" "$STEPS_CONTEXT"
echo "******************************"
echo "runner:" "$RUNNER_CONTEXT"
echo "******************************"
echo "secrets:" "$SECRETS_CONTEXT"
echo "******************************"
echo "strategy:" "$STRATEGY_CONTEXT"
echo "******************************"
echo "matrix:" "$MATRIX_CONTEXT"
echo "******************************"
echo "needs:" "$NEEDS_CONTEXT"
echo "******************************"
echo "inputs:" "$INPUTS_CONTEXT"
echo "******************************"

- uses: actions/checkout@v3

# fail-fast step to check if the version has been bumped
# when running manually, there won't be a version line change, so we need to skip this step in that case
- name: Detect version bump
run: |
set -euxo pipefail # stop on errors, print commands, fail on pipe fails


# get the next version as the version currently set in the root package.json
NEXT=$(jq -r '.version' package.json)
echo "Next version: $NEXT"

# checkout the repo back to before this pr
git checkout ${{ github.event.before }}

# get the previous version as the version currently set in the root package.json in the before state
PREV=$(jq -r '.version' package.json)
echo "Previous version: $PREV"

# switch back to the current state
git switch -

# break next and previous versions into major, minor, patch
NEXT_MAJOR=$(echo $NEXT | cut -d. -f1)
NEXT_MINOR=$(echo $NEXT | cut -d. -f2)
NEXT_PATCH=$(echo $NEXT | cut -d. -f3)
PREV_MAJOR=$(echo $PREV | cut -d. -f1)
PREV_MINOR=$(echo $PREV | cut -d. -f2)
PREV_PATCH=$(echo $PREV | cut -d. -f3)

# compare the versions, checking for an *increasing* version

if [[ $NEXT_MAJOR -gt $PREV_MAJOR ]]; then
echo "Major version bump"
elif [[ $NEXT_MAJOR -eq $PREV_MAJOR && $NEXT_MINOR -gt $PREV_MINOR ]]; then
echo "Minor version bump"
elif [[ $NEXT_MAJOR -eq $PREV_MAJOR && $NEXT_MINOR -eq $PREV_MINOR && $NEXT_PATCH -gt $PREV_PATCH ]]; then
echo "Patch version bump"
else
echo "Version not bumped / not an increasing version"
exit 1
fi
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
name: consistent_versions
# Check the node versions are consistent across packages

name: consistent_engine_node

on:
pull_request:
branches: [main]
branches: [main, dev, release/*]
paths:
- '**/package.json'
- 'package.json'
- '.github/workflows/consistent_engine_node.yml'
workflow_dispatch:

concurrency:
Expand All @@ -20,6 +22,7 @@ env:
jobs:
check:
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
steps:
- name: Print contexts
env:
Expand Down Expand Up @@ -61,22 +64,19 @@ jobs:

- uses: actions/checkout@v3

- name: Check versions are consistent amongst packages
- name: Check contract version matches provider version
run: |
# for each package, get the version then filter to unique versions
versions=$(npx --workspaces npm pkg get version | grep "@" | awk '{print $2}' | uniq)
# if more than one version is detected, fail
if [ $(echo "$versions" | wc -l) -gt 1 ]; then
echo "Versions are not consistent amongst packages:"
echo "$versions"
exit 1
fi
# if version doesn't match the root workspace version, fail
root_version=$(npm pkg get version)
if [ "$versions" != "$root_version" ]; then
echo "Version is not consistent with root workspace version:"
set -euxo pipefail # stop on errors, print commands, fail on pipe fails

# find all package.json files, recursively
pkgJsons=$(find . -name package.json -prune -not -path '*/node_modules/*' -not -path '*/.next/*')

# extract the node version from the package.json files
versions=$(jq -r '.engines.node' $pkgJsons)

# ensure all node versions are the same
if [ $(echo "$versions" | uniq | wc -l) -ne 1 ]; then
echo "Node versions are not consistent across packages"
echo "$versions"
echo "$root_version"
exit 1
fi
# else versions are consistent, pass
fi
Loading
Loading