From bdedad89e5bbc1bc4796eed41178ab6554e17224 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Mon, 3 Jun 2024 15:55:27 +0100 Subject: [PATCH 01/72] add dev branch to auto merge --- .github/workflows/auto_merge.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto_merge.yml b/.github/workflows/auto_merge.yml index 2adc98bddb..a14aba39de 100644 --- a/.github/workflows/auto_merge.yml +++ b/.github/workflows/auto_merge.yml @@ -2,7 +2,7 @@ name: auto_merge on: pull_request: - branches: [main] + branches: [main, dev, release/*] types: - opened - reopened From 66552cc0c897139b0bcba9529e0863979e7eb82c Mon Sep 17 00:00:00 2001 From: George Oastler Date: Mon, 3 Jun 2024 15:57:16 +0100 Subject: [PATCH 02/72] make clippy run on new branch setup --- .github/workflows/clippy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml index 0baf95ebc9..cf236b2e57 100644 --- a/.github/workflows/clippy.yml +++ b/.github/workflows/clippy.yml @@ -2,7 +2,7 @@ name: clippy on: pull_request: - branches: [main] + branches: [main, dev, release/*] paths: - '**.rs' - '.github/workflows/clippy.yml' From 965609ac265790f1d796b75d542f77e7c6508493 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Mon, 3 Jun 2024 16:00:02 +0100 Subject: [PATCH 03/72] remove version checker workflow --- .github/workflows/consistent_versions.yml | 82 ----------------------- 1 file changed, 82 deletions(-) delete mode 100644 .github/workflows/consistent_versions.yml diff --git a/.github/workflows/consistent_versions.yml b/.github/workflows/consistent_versions.yml deleted file mode 100644 index 263066616b..0000000000 --- a/.github/workflows/consistent_versions.yml +++ /dev/null @@ -1,82 +0,0 @@ -name: consistent_versions - -on: - pull_request: - branches: [main] - paths: - - '**/package.json' - - 'package.json' - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -env: - CARGO_TERM_COLOR: always - ENVIRONMENT: development - GH_TOKEN: ${{ github.token }} - -jobs: - check: - runs-on: ubuntu-latest - 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 - - - name: Check versions are consistent amongst packages - 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:" - echo "$versions" - echo "$root_version" - exit 1 - fi - # else versions are consistent, pass From 09ab63bf455021e823cfd4bc3b513c2acc8e46f5 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Mon, 3 Jun 2024 16:00:26 +0100 Subject: [PATCH 04/72] add dev and release branch triggers to consistent workflow name checker --- .github/workflows/consistent_workflow_names.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/consistent_workflow_names.yml b/.github/workflows/consistent_workflow_names.yml index b4836c90e1..a67d780027 100644 --- a/.github/workflows/consistent_workflow_names.yml +++ b/.github/workflows/consistent_workflow_names.yml @@ -2,7 +2,7 @@ name: consistent_workflow_names on: pull_request: - branches: [main] + branches: [main, dev, release/*] # only when workflow file is changed paths: ['.github/workflows/**'] From fe520111570a5817f244b96bc44692899939d414 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Mon, 3 Jun 2024 16:01:05 +0100 Subject: [PATCH 05/72] Delete create_diagram.yml --- .github/workflows/create_diagram.yml | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 .github/workflows/create_diagram.yml diff --git a/.github/workflows/create_diagram.yml b/.github/workflows/create_diagram.yml deleted file mode 100644 index b5f0ec24b9..0000000000 --- a/.github/workflows/create_diagram.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: create_diagram -on: - workflow_dispatch: {} - pull_request: - branches: - - main -jobs: - get_data: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: githubocto/repo-visualizer@main - with: - branch: repo-diagram From 3ff530dfbafa58275e9da11100a89d47f3ffa78c Mon Sep 17 00:00:00 2001 From: George Oastler Date: Mon, 3 Jun 2024 16:01:39 +0100 Subject: [PATCH 06/72] add dev and release branch triggers to lint workflow --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a52991d482..2c2b697f06 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -2,7 +2,7 @@ name: lint on: pull_request: - branches: [main] + branches: [main, dev, release/*] workflow_dispatch: concurrency: From a8d5a28f4bec145510a0a3e541901949799f4acf Mon Sep 17 00:00:00 2001 From: George Oastler Date: Mon, 3 Jun 2024 16:03:29 +0100 Subject: [PATCH 07/72] add release and dev branch triggers to provider_image workflow --- .github/workflows/provider_image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/provider_image.yml b/.github/workflows/provider_image.yml index 60f67cd133..370d8fe5a4 100644 --- a/.github/workflows/provider_image.yml +++ b/.github/workflows/provider_image.yml @@ -2,7 +2,7 @@ name: provider_image on: pull_request: - branches: [main] + branches: [main, dev, release/*] paths: - 'docker/**' - 'dev/**' From ae8d8f986090d888b8e424efe89569a6c6fabbe9 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Mon, 3 Jun 2024 16:04:50 +0100 Subject: [PATCH 08/72] remove release drafter --- .github/release-drafter.yml | 5 ---- .github/weekly-digest.yml | 7 ----- .github/workflows/release_drafter.yml | 39 --------------------------- 3 files changed, 51 deletions(-) delete mode 100644 .github/release-drafter.yml delete mode 100644 .github/weekly-digest.yml delete mode 100644 .github/workflows/release_drafter.yml diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml deleted file mode 100644 index d8cd3a39c4..0000000000 --- a/.github/release-drafter.yml +++ /dev/null @@ -1,5 +0,0 @@ -# https://github.com/release-drafter/release-drafter -template: | - ## What’s Changed - - $CHANGES diff --git a/.github/weekly-digest.yml b/.github/weekly-digest.yml deleted file mode 100644 index 08cced6393..0000000000 --- a/.github/weekly-digest.yml +++ /dev/null @@ -1,7 +0,0 @@ -# Configuration for weekly-digest - https://github.com/apps/weekly-digest -publishDay: mon -canPublishIssues: true -canPublishPullRequests: true -canPublishContributors: true -canPublishStargazers: true -canPublishCommits: true diff --git a/.github/workflows/release_drafter.yml b/.github/workflows/release_drafter.yml deleted file mode 100644 index 9cc9990642..0000000000 --- a/.github/workflows/release_drafter.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: release_drafter - -on: - push: - # branches to consider in the event; optional, defaults to all - branches: - - main - # pull_request event is required only for autolabeler - pull_request: - # Only following types are handled by the action, but one can default to all as well - types: [opened, reopened, synchronize] - workflow_dispatch: - -permissions: - contents: read - -jobs: - update_release_draft: - permissions: - # write permission is required to create a github release - contents: write - # write permission is required for autolabeler - # otherwise, read permission is required at least - pull-requests: write - runs-on: ubuntu-latest - steps: - # (Optional) GitHub Enterprise requires GHE_HOST variable set - #- name: Set GHE_HOST - # run: | - # echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV - - # Drafts your next Release notes as Pull Requests are merged into "master" - - uses: release-drafter/release-drafter@v5 - # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml - # with: - # config-name: my-config.yml - # disable-autolabeler: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From e13f1bb427570541ab7904ea8285f43b0728cb89 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Mon, 3 Jun 2024 16:05:10 +0100 Subject: [PATCH 09/72] add dev and release branches to rustfmt workflow --- .github/workflows/rustfmt.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rustfmt.yml b/.github/workflows/rustfmt.yml index 5313ea0fb1..7ea2dbc6f1 100644 --- a/.github/workflows/rustfmt.yml +++ b/.github/workflows/rustfmt.yml @@ -2,7 +2,7 @@ name: rustfmt on: pull_request: - branches: [main] + branches: [main, dev, release/*] paths: - '**.rs' - '.github/workflows/rustfmt.yml' From ef466e627afd660896d9aaa78dfa9a2edac9e3a0 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Mon, 3 Jun 2024 16:05:33 +0100 Subject: [PATCH 10/72] add dev and release branches to protocol test workflow --- .github/workflows/tests_protocol.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/tests_protocol.yml b/.github/workflows/tests_protocol.yml index bbf6adb4c3..2a80d45f5b 100644 --- a/.github/workflows/tests_protocol.yml +++ b/.github/workflows/tests_protocol.yml @@ -2,8 +2,7 @@ name: tests_protocol on: pull_request: - branches: - - 'main' + branches: [main, dev, release/*] paths: - 'protocol/**' - '.github/workflows/tests_protocol.yml' From dffd3b6a6d88852219bab151c8bbdc7b702a5178 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Mon, 3 Jun 2024 16:05:59 +0100 Subject: [PATCH 11/72] add dev and release branches triggers to tests workflow --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index be5ced2e05..00e342a04b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -2,7 +2,7 @@ name: tests on: pull_request: - branches: [main] + branches: [main, dev, release/*] paths: - 'docker/**' - 'packages/**' From deed023c95cf76db4ba22b1edf8884bce07c7b8d Mon Sep 17 00:00:00 2001 From: George Oastler Date: Mon, 3 Jun 2024 16:06:21 +0100 Subject: [PATCH 12/72] add dev and release branch triggers to webpack bundling workflow --- .github/workflows/webpack_bundling.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/webpack_bundling.yml b/.github/workflows/webpack_bundling.yml index 6931b9002c..f3e514f7ec 100644 --- a/.github/workflows/webpack_bundling.yml +++ b/.github/workflows/webpack_bundling.yml @@ -2,7 +2,7 @@ name: webpack_bundling on: pull_request: - branches: [main] + branches: [main, dev, release/*] paths: - 'src/**' - 'package.json' From 308df3391ee377037b6ed194fe6d6f6c7d9843e4 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Mon, 3 Jun 2024 16:09:32 +0100 Subject: [PATCH 13/72] switch cache creation to be post pr to dev --- .github/workflows/post_pr.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/post_pr.yml b/.github/workflows/post_pr.yml index 3ed76da116..6dd253dd39 100644 --- a/.github/workflows/post_pr.yml +++ b/.github/workflows/post_pr.yml @@ -1,11 +1,11 @@ name: post_pr -# 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 to dev, or manually triggered +# we do this because any branch can use caches built on dev, whereas caches built on other branches are only available to that branch and its children on: push: branches: - - 'main' + - 'dev' workflow_dispatch: concurrency: From 1eef4c0b39cefdc8f6c335c486a682bc32d1b607 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Mon, 3 Jun 2024 16:16:37 +0100 Subject: [PATCH 14/72] rename post_pr workflow to cache --- .github/workflows/{post_pr.yml => cache.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{post_pr.yml => cache.yml} (100%) diff --git a/.github/workflows/post_pr.yml b/.github/workflows/cache.yml similarity index 100% rename from .github/workflows/post_pr.yml rename to .github/workflows/cache.yml From 0aadf03ac3ab590fc44c146ae6a835aaaaad69de Mon Sep 17 00:00:00 2001 From: George Oastler Date: Mon, 3 Jun 2024 16:32:26 +0100 Subject: [PATCH 15/72] Update cache.yml --- .github/workflows/cache.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/cache.yml b/.github/workflows/cache.yml index 6dd253dd39..36e7db1c8b 100644 --- a/.github/workflows/cache.yml +++ b/.github/workflows/cache.yml @@ -4,8 +4,7 @@ name: post_pr # we do this because any branch can use caches built on dev, whereas caches built on other branches are only available to that branch and its children on: push: - branches: - - 'dev' + branches: [dev] workflow_dispatch: concurrency: From 5215a52dd7a67cbc33d5ccfdd49e8d7afe44d2ad Mon Sep 17 00:00:00 2001 From: George Oastler Date: Mon, 3 Jun 2024 18:02:56 +0100 Subject: [PATCH 16/72] publish workflow --- .github/workflows/publish.yml | 290 ++---------------------- dev/gh-actions/package.json | 1 + dev/gh-actions/src/dockerTags.ts | 61 +++++ dev/gh-actions/src/listDockerTags.ts | 12 + dev/gh-actions/src/previousDockerTag.ts | 36 +++ package-lock.json | 34 ++- 6 files changed, 162 insertions(+), 272 deletions(-) create mode 100644 dev/gh-actions/src/dockerTags.ts create mode 100644 dev/gh-actions/src/listDockerTags.ts create mode 100644 dev/gh-actions/src/previousDockerTag.ts diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 859c9fd422..0c050bd157 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -8,8 +8,6 @@ on: paths: # only when the package.json file changes - 'package.json' - # or run manually - workflow_dispatch: jobs: publish: @@ -53,51 +51,19 @@ jobs: echo "inputs:" "$INPUTS_CONTEXT" echo "******************************" - - uses: actions/checkout@v3 - with: - # fetch all history + branches - fetch-depth: 0 - - name: Dockerhub login run: | echo "Logging into Docker Hub." echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin 2> /dev/null - # 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 + - uses: actions/checkout@v3 + with: + # fetch all history + branches + fetch-depth: 0 + + - name: Next version id: next_version run: | - if [[ "${{ github.event_name }}" == 'workflow_dispatch' ]]; then - echo "manual run, skipping version check" - exit 0 - fi - - # use git to look for differences in package.json between the before and after state - # before and after git sha's are passed in as env vars by github - diff=$(git show --pretty=format: --no-notes ${{ github.event.before }}..${{ github.event.after }} -- package.json | cat) - echo "diff:" - echo "$diff" - echo "" - - # grep for the version line - version_changes=$(echo "$diff" | grep -e "[-\+]\s*\"version\"" || true) - echo "version_changes:" - echo "$version_changes" - echo "" - - # if the version line has changed then we know there's been a version change. Not necessarily bumped up, though! - # the next version will be whatever is currently in the package.json file - # subsequent steps can choose whether the version has been bumped or not. All we know at this stage is the version has been changed, i.e. new_version != old_version, but we don't know whether new_version > old_version or new_version < old_version - if [[ -n "$version_changes" ]]; then - echo "version has changed" - echo "bump=true" >> $GITHUB_OUTPUT - else - echo "version has not changed" - # skip remaining steps which bump the version - echo "bump=false" >> $GITHUB_OUTPUT - exit 0 - fi VERSION=$(cat package.json | jq -r '.version' || echo "0.0.0") # split into major, minor, patch @@ -115,237 +81,22 @@ jobs: echo "minor=$MINOR" >> $GITHUB_OUTPUT echo "patch=$PATCH" >> $GITHUB_OUTPUT - # check for version bump against github release - - name: Check version github - id: check_version_github - if: steps.next_version.outputs.bump == 'true' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - # get the current version number from latest release on gh - VERSION=$(gh release list --limit 1 | awk '{print $1}' | tr -d v) - - if [[ -z "$VERSION" ]]; then - echo "Failed to get current version" - exit 1 - fi - - MAJOR=$(echo $VERSION | cut -d. -f1) - MINOR=$(echo $VERSION | cut -d. -f2) - PATCH=$(echo $VERSION | cut -d. -f3) - echo "version=$VERSION" >> $GITHUB_OUTPUT - echo "major=$MAJOR" >> $GITHUB_OUTPUT - echo "minor=$MINOR" >> $GITHUB_OUTPUT - echo "patch=$PATCH" >> $GITHUB_OUTPUT - echo "version: $VERSION" - - if [[ "${{ steps.next_version.outputs.major }}" -gt "$MAJOR" ]]; then - echo "major version bump detected" - echo "bump=true" >> $GITHUB_OUTPUT - elif [[ "${{ steps.next_version.outputs.minor }}" -gt "$MINOR" ]]; then - echo "minor version bump detected" - echo "bump=true" >> $GITHUB_OUTPUT - elif [[ "${{ steps.next_version.outputs.patch }}" -gt "$PATCH" ]]; then - echo "patch version bump detected" - echo "bump=true" >> $GITHUB_OUTPUT - else - echo "no version bump detected" - echo "bump=false" >> $GITHUB_OUTPUT - fi - - - name: Check version npm - id: check_version_npm - if: steps.next_version.outputs.bump == 'true' - run: | - # get the current version number from latest release on npm (use procaptcha as the baseline, as workspace package is not published) - VERSION=$(npm view @prosopo/procaptcha version) - - if [[ -z "$VERSION" ]]; then - echo "Failed to get current version" - exit 1 - fi - - MAJOR=$(echo $VERSION | cut -d. -f1) - MINOR=$(echo $VERSION | cut -d. -f2) - PATCH=$(echo $VERSION | cut -d. -f3) - echo "version=$VERSION" >> $GITHUB_OUTPUT - echo "major=$MAJOR" >> $GITHUB_OUTPUT - echo "minor=$MINOR" >> $GITHUB_OUTPUT - echo "patch=$PATCH" >> $GITHUB_OUTPUT - echo "version: $VERSION" - - if [[ "${{ steps.next_version.outputs.major }}" -gt "$MAJOR" ]]; then - echo "major version bump detected" - echo "bump=true" >> $GITHUB_OUTPUT - elif [[ "${{ steps.next_version.outputs.minor }}" -gt "$MINOR" ]]; then - echo "minor version bump detected" - echo "bump=true" >> $GITHUB_OUTPUT - elif [[ "${{ steps.next_version.outputs.patch }}" -gt "$PATCH" ]]; then - echo "patch version bump detected" - echo "bump=true" >> $GITHUB_OUTPUT - else - echo "no version bump detected" - echo "bump=false" >> $GITHUB_OUTPUT - fi - - - name: Check version docker js_server - id: check_version_docker_js_server - if: steps.next_version.outputs.bump == 'true' - run: | - # get the current version number from latest release on docker - VERSION=$(curl -L -s 'https://registry.hub.docker.com/v2/repositories/prosopo/js_server/tags/' | jq ".results[].name" | grep -E -o "[0-9]+\.[0-9]+\.[0-9]+" | head -n 1) - - if [[ -z "$VERSION" ]]; then - echo "Failed to get current version" - exit 1 - fi - - MAJOR=$(echo $VERSION | cut -d. -f1) - MINOR=$(echo $VERSION | cut -d. -f2) - PATCH=$(echo $VERSION | cut -d. -f3) - echo "version=$VERSION" >> $GITHUB_OUTPUT - echo "major=$MAJOR" >> $GITHUB_OUTPUT - echo "minor=$MINOR" >> $GITHUB_OUTPUT - echo "patch=$PATCH" >> $GITHUB_OUTPUT - echo "version: $VERSION" - - if [[ "${{ steps.next_version.outputs.major }}" -gt "$MAJOR" ]]; then - echo "major version bump detected" - echo "bump=true" >> $GITHUB_OUTPUT - elif [[ "${{ steps.next_version.outputs.minor }}" -gt "$MINOR" ]]; then - echo "minor version bump detected" - echo "bump=true" >> $GITHUB_OUTPUT - elif [[ "${{ steps.next_version.outputs.patch }}" -gt "$PATCH" ]]; then - echo "patch version bump detected" - echo "bump=true" >> $GITHUB_OUTPUT - else - echo "no version bump detected" - echo "bump=false" >> $GITHUB_OUTPUT - fi - - - name: Check version docker provider - id: check_version_docker_provider - if: steps.next_version.outputs.bump == 'true' - run: | - # get the current version number from latest release on docker - VERSION=$(curl -L -s 'https://registry.hub.docker.com/v2/repositories/prosopo/provider/tags/' | jq ".results[].name" | grep -E -o "[0-9]+\.[0-9]+\.[0-9]+" | head -n 1) - - if [[ -z "$VERSION" ]]; then - echo "Failed to get current version" - exit 1 - fi - - MAJOR=$(echo $VERSION | cut -d. -f1) - MINOR=$(echo $VERSION | cut -d. -f2) - PATCH=$(echo $VERSION | cut -d. -f3) - echo "version=$VERSION" >> $GITHUB_OUTPUT - echo "major=$MAJOR" >> $GITHUB_OUTPUT - echo "minor=$MINOR" >> $GITHUB_OUTPUT - echo "patch=$PATCH" >> $GITHUB_OUTPUT - echo "version: $VERSION" - - if [[ "${{ steps.next_version.outputs.major }}" -gt "$MAJOR" ]]; then - echo "major version bump detected" - echo "bump=true" >> $GITHUB_OUTPUT - elif [[ "${{ steps.next_version.outputs.minor }}" -gt "$MINOR" ]]; then - echo "minor version bump detected" - echo "bump=true" >> $GITHUB_OUTPUT - elif [[ "${{ steps.next_version.outputs.patch }}" -gt "$PATCH" ]]; then - echo "patch version bump detected" - echo "bump=true" >> $GITHUB_OUTPUT - else - echo "no version bump detected" - echo "bump=false" >> $GITHUB_OUTPUT - fi - - - name: Should bump? - id: check_version_any - run: | - bump=false - # only bump if any of the version checks have detected a bump - if [[ "${{ steps.check_version_github.outputs.bump }}" == 'true' ]]; then - bump=true - echo "github bump required" - fi - if [[ "${{ steps.check_version_npm.outputs.bump }}" == 'true' ]]; then - bump=true - echo "npm bump required" - fi - if [[ "${{ steps.check_version_docker_js_server.outputs.bump }}" == 'true' ]]; then - bump=true - echo "docker js_server bump required" - fi - if [[ "${{ steps.check_version_docker_provider.outputs.bump }}" == 'true' ]]; then - bump=true - echo "docker provider bump required" - fi - if [[ "$bump" == 'true' ]]; then - echo "bump=true" >> $GITHUB_OUTPUT - echo "something needs bumping" - else - echo "bump=false" >> $GITHUB_OUTPUT - echo "nothing needs bumping" - fi - - # get the latest build from the cache produced in the post_pr workflow - - - run: mkdir -p protocol/cargo-cache - if: steps.check_version_any.outputs.bump == 'true' - - run: mkdir -p protocol/target - if: steps.check_version_any.outputs.bump == 'true' - - run: mkdir -p node_modules - if: steps.check_version_any.outputs.bump == 'true' - - run: mkdir -p ~/.cache/Cypress - if: steps.check_version_any.outputs.bump == 'true' - - - name: Restore cache - if: steps.check_version_any.outputs.bump == 'true' - 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 - if: steps.check_version_any.outputs.bump == 'true' - - run: ls -la protocol/cargo-cache || true - if: steps.check_version_any.outputs.bump == 'true' - - run: ls -la protocol/target/ink || true - if: steps.check_version_any.outputs.bump == 'true' - - run: ls -la node_modules || true - if: steps.check_version_any.outputs.bump == 'true' - - uses: actions/setup-node@v3 - if: steps.check_version_any.outputs.bump == 'true' with: node-version-file: '.nvmrc' - run: npm i -g npm@$(cat package.json | jq -r .engines.npm) - if: steps.check_version_any.outputs.bump == 'true' - - name: Install - if: steps.check_version_any.outputs.bump == 'true' - run: | - npm ci + - run: npm ci - # at this point there should be a build in the cache, so we can begin building artifacts for the release + # build from scratch to ensure nothing bought over from cache - name: Build packages - if: steps.check_version_any.outputs.bump == 'true' run: | echo "Building packages..." npm run build:all npm run build:all:cjs - name: Build the contract sources - if: steps.check_version_any.outputs.bump == 'true' run: | cd protocol/dev npm run build @@ -357,7 +108,6 @@ jobs: npm run docs - name: Build JS bundle - if: steps.check_version_any.outputs.bump == 'true' run: | # Copy the rococo env file to production env file echo "Copying the rococo env to production env file in procaptcha-bundle" @@ -370,17 +120,28 @@ jobs: NODE_ENV=production npm run bundle:prod - name: Build docker js_server - if: steps.check_version_any.outputs.bump == 'true' run: | # Set the JS location in the container JS_FOLDER="/usr/share/nginx/html/js" # Get the most recent version of the js_server image - docker pull prosopo/js_server:${{ steps.check_version_docker_js_server.outputs.version }} + docker pull prosopo/js_server:${{ steps.next_version.outputs.version }} + + # get the previous version number from latest release on docker + VERSION=$(cd dev/gh-actions && npx tsx src/previousDockerTag.ts prosopo js_server ${{ steps.next_version.outputs.version }}) + + if [[ -z "$VERSION" ]]; then + echo "Failed to get previous version" + exit 1 + fi + + MAJOR=$(echo $VERSION | cut -d. -f1) + MINOR=$(echo $VERSION | cut -d. -f2) + PATCH=$(echo $VERSION | cut -d. -f3) # Create a temporary container from the latest image echo "Building Docker image..." - OLD_CONTAINER_ID=$(docker create prosopo/js_server:${{ steps.check_version_docker_js_server.outputs.version }}) + OLD_CONTAINER_ID=$(docker create prosopo/js_server:$VERSION) # Remove the old js temp folder rm -rf ./js_bundles_host_temp @@ -421,7 +182,6 @@ jobs: - name: Github release continue-on-error: true id: publish_github - if: steps.check_version_github.outputs.bump == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -444,7 +204,6 @@ jobs: - name: Npm release continue-on-error: true id: publish_release - if: steps.check_version_npm.outputs.bump == 'true' run: | if [[ "${{ vars.HOST_GITHUB_ACTIONS }}" == true ]]; then echo "Running on GitHub Actions" @@ -474,7 +233,6 @@ jobs: - name: Docker js_server release continue-on-error: true id: publish_docker_js_server - if: steps.check_version_docker_js_server.outputs.bump == 'true' run: | # Push the new image to Docker Hub echo "Pushing Docker image..." @@ -537,15 +295,12 @@ jobs: # Add support for more platforms with QEMU (optional) # https://github.com/docker/setup-qemu-action - name: Set up QEMU - if: steps.check_version_docker_js_server.outputs.bump == 'true' uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - if: steps.check_version_docker_js_server.outputs.bump == 'true' uses: docker/setup-buildx-action@v3 - name: Build the production CLI package - if: steps.check_version_docker_js_server.outputs.bump == 'true' run: | echo "Building the production CLI package..." # Copy the rococo env file to production env file @@ -563,7 +318,6 @@ jobs: cd ../.. - name: Build and push the Provider Container - if: steps.check_version_docker_js_server.outputs.bump == 'true' id: publish_docker_provider continue-on-error: true uses: docker/build-push-action@v5 diff --git a/dev/gh-actions/package.json b/dev/gh-actions/package.json index d0159a0089..4800e759e8 100644 --- a/dev/gh-actions/package.json +++ b/dev/gh-actions/package.json @@ -25,6 +25,7 @@ }, "dependencies": { "@octokit/graphql": "^7.0.2", + "axios": "^1.7.2", "node-fetch": "^3.3.2", "octokit": "^3.1.2" }, diff --git a/dev/gh-actions/src/dockerTags.ts b/dev/gh-actions/src/dockerTags.ts new file mode 100644 index 0000000000..181cfc9c56 --- /dev/null +++ b/dev/gh-actions/src/dockerTags.ts @@ -0,0 +1,61 @@ +// Copyright 2021-2024 Prosopo (UK) Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +import axios from 'axios'; + +export async function fetchTags(namespace: string, repository: string): Promise { + const tags: string[] = []; + let page = 1; + let nextPageUrl: string | null = `https://hub.docker.com/v2/repositories/${namespace}/${repository}/tags/?page=${page}`; + + while (nextPageUrl) { + try { + const response: any = await axios.get(nextPageUrl); + const data = response.data; + tags.push(...data.results.map((tag: any) => tag.name)) + nextPageUrl = data.next; + page++; + } catch (error) { + console.error(`Error fetching tags: ${error}`); + break; + } + } + + tags.sort(semVerLt) + + return tags.reverse(); +} + +export const semVerLt = (a: string, b: string): number => { + const aParts = a.split('.').map((part) => parseInt(part, 10)); + const bParts = b.split('.').map((part) => parseInt(part, 10)); + + if (aParts.length !== bParts.length || aParts.length !== 3) { + // not semver, so compare lexicographically + return a.localeCompare(b); + } + + for (let i = 0; i < aParts.length; i++) { + if (aParts[i]! < bParts[i]!) { + return -1; + } else if (aParts[i]! > bParts[i]!) { + return 1; + } + } + + return 0; +} + +export const isSemVer = (tag: string): boolean => { + return /^\d+\.\d+\.\d+$/.test(tag); +} diff --git a/dev/gh-actions/src/listDockerTags.ts b/dev/gh-actions/src/listDockerTags.ts new file mode 100644 index 0000000000..df9687f965 --- /dev/null +++ b/dev/gh-actions/src/listDockerTags.ts @@ -0,0 +1,12 @@ +import { fetchTags } from "./dockerTags.js"; + + +const main = async () => { + // get args + const args = process.argv.slice(2); + const tags = await fetchTags(String(args[0]), String(args[1])) + console.log(tags) +} + + +main() diff --git a/dev/gh-actions/src/previousDockerTag.ts b/dev/gh-actions/src/previousDockerTag.ts new file mode 100644 index 0000000000..5c630adac5 --- /dev/null +++ b/dev/gh-actions/src/previousDockerTag.ts @@ -0,0 +1,36 @@ +// Copyright 2021-2024 Prosopo (UK) Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +import axios from 'axios'; +import { fetchTags, isSemVer, semVerLt } from './dockerTags.js'; + +const main = async () => { + // get args + const args = process.argv.slice(2); + // tags will be sorted in descending order + const tags = await fetchTags(String(args[0]), String(args[1])) + // find the tag that is previous to the given tag + const target = String(args[2]); + for (const tag of tags) { + if (isSemVer(tag) === false) { + continue; + } + if (semVerLt(tag, target) === -1) { + // found the previous tag + console.log(tag); + return; + } + } +} + +main() diff --git a/package-lock.json b/package-lock.json index 8d8a33a681..367b9552b2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -575,6 +575,7 @@ "license": "ISC", "dependencies": { "@octokit/graphql": "^7.0.2", + "axios": "^1.7.2", "node-fetch": "^3.3.2", "octokit": "^3.1.2" }, @@ -9673,8 +9674,7 @@ "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", - "devOptional": true + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" }, "node_modules/at-least-node": { "version": "1.0.0", @@ -9722,6 +9722,34 @@ "node": ">=4" } }, + "node_modules/axios": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.2.tgz", + "integrity": "sha512-2A8QhOMrbomlDuiLeK9XibIBzuHeRcqqNOHp0Cyp5EoJ1IFDh+XZH3A6BkXtv0K4gFGCI0Y4BM7B1wOEi0Rmgw==", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/axios/node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/axios/node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, "node_modules/axobject-query": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-3.2.1.tgz", @@ -11247,7 +11275,6 @@ "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "devOptional": true, "dependencies": { "delayed-stream": "~1.0.0" }, @@ -12547,7 +12574,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", - "devOptional": true, "engines": { "node": ">=0.4.0" } From 270e72199923ecc3253d00e114ed00a10a32024a Mon Sep 17 00:00:00 2001 From: George Oastler Date: Thu, 13 Jun 2024 17:52:19 +0100 Subject: [PATCH 17/72] Update cache.yml --- .github/workflows/cache.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cache.yml b/.github/workflows/cache.yml index 36e7db1c8b..904ba7a39c 100644 --- a/.github/workflows/cache.yml +++ b/.github/workflows/cache.yml @@ -1,10 +1,10 @@ name: post_pr -# on push to dev, or manually triggered +# on push to main, or manually triggered # we do this because any branch can use caches built on dev, whereas caches built on other branches are only available to that branch and its children on: push: - branches: [dev] + branches: [main] workflow_dispatch: concurrency: @@ -59,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 From 19dcb44f8e51c6a51724752d6c414dc1b63a80ba Mon Sep 17 00:00:00 2001 From: George Oastler Date: Mon, 1 Jul 2024 14:59:50 +0100 Subject: [PATCH 18/72] fix contract js/rust version check workflow --- .github/workflows/contract_version.yml | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/contract_version.yml b/.github/workflows/contract_version.yml index 0c2f1c4cb5..8e7d5d371e 100644 --- a/.github/workflows/contract_version.yml +++ b/.github/workflows/contract_version.yml @@ -65,12 +65,16 @@ jobs: - name: Check contract version matches provider version run: | set -eu - provider=$(cat packages/provider/package.json | jq -r '.version') - find protocol/target/ink/*/ -name "Cargo.toml" | while read line; do - contract=$(cat $line | grep -m 1 "version = " | cut -d '"' -f 2) - echo "checking version in $line" - if [[ "$contract" != "$provider" ]]; then - echo "version mismatch: $contract != $provider" - exit 1 - fi - done + # get the version of the contract in js pkg + for contract in contracts/*; do + echo "checking version in $contract" + jsVer=$(cat $contract/package.json | jq -r .version) + echo "js version: $jsVer" + # get the version of the contract in rust pkg + # assuming the contract version is the first version line in Cargo.toml + rustVer=$(cat protocol/contracts/$contract/Cargo.toml | grep -m 1 "version = " | cut -d '"' -f 2) + if [[ "$jsVer" != "$rustVer" ]]; then + echo "version mismatch: $jsVer != $rustVer" + exit 1 + fi + done From 6d97672aa645b097c7dd36c368800459c57b0893 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Mon, 1 Jul 2024 15:07:54 +0100 Subject: [PATCH 19/72] install concurrently and cypress as workspace deps --- .github/workflows/cypress.yml | 4 - package-lock.json | 154 ++++++++++++++++++++++++++++++++-- package.json | 2 + 3 files changed, 151 insertions(+), 9 deletions(-) diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 960a175b6c..9ba85fc433 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -120,10 +120,6 @@ jobs: # by the cypress tests to find the elements they need to interact with - run: NODE_ENV=test npm -w @prosopo/procaptcha-bundle run bundle:dev - # Needs concurrently to avoid vite hanging forever https://github.com/vitejs/vite/discussions/8745 - - name: Install concurrently and cypress - run: npm i concurrently cypress - - name: Run the cypress tests on client-example run: | npx concurrently "npm run start:server" "npm run start:provider" "npm run start:demo" "sleep 10s && npm -w @prosopo/cypress-shared run cypress:run:client-example" --success "first" --kill-others diff --git a/package-lock.json b/package-lock.json index cb162e8368..50b26d80d7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,6 +31,8 @@ "@typescript-eslint/parser": "^6.0.0", "@vitest/coverage-v8": "^1.3.1", "babel-plugin-import": "^1.13.6", + "concurrently": "^8.2.2", + "cypress": "^13.12.0", "depcheck": "^1.4.7", "eslint": "^8.55.0", "eslint-config-prettier": "^8.5.0", @@ -163,8 +165,7 @@ "electron": "25.8.4", "react": "^18.3.1", "react-dom": "^18.3.1", - "react-router-dom": "^6.22.3", - "web-vitals": "^2.1.4" + "react-router-dom": "^6.22.3" }, "devDependencies": { "@prosopo/cli": "1.0.2", @@ -11563,6 +11564,118 @@ "safe-buffer": "~5.1.0" } }, + "node_modules/concurrently": { + "version": "8.2.2", + "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-8.2.2.tgz", + "integrity": "sha512-1dP4gpXFhei8IOtlXRE/T/4H88ElHgTiUzh71YUmtjTEHMSRS2Z/fgOxHSxxusGHogsRfxNq1vyAwxSC+EVyDg==", + "dev": true, + "dependencies": { + "chalk": "^4.1.2", + "date-fns": "^2.30.0", + "lodash": "^4.17.21", + "rxjs": "^7.8.1", + "shell-quote": "^1.8.1", + "spawn-command": "0.0.2", + "supports-color": "^8.1.1", + "tree-kill": "^1.2.2", + "yargs": "^17.7.2" + }, + "bin": { + "conc": "dist/bin/concurrently.js", + "concurrently": "dist/bin/concurrently.js" + }, + "engines": { + "node": "^14.13.0 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/open-cli-tools/concurrently?sponsor=1" + } + }, + "node_modules/concurrently/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/concurrently/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/concurrently/node_modules/chalk/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/concurrently/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/concurrently/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/concurrently/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/concurrently/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, "node_modules/confbox": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/confbox/-/confbox-0.1.7.tgz", @@ -12050,9 +12163,9 @@ "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==" }, "node_modules/cypress": { - "version": "13.11.0", - "resolved": "https://registry.npmjs.org/cypress/-/cypress-13.11.0.tgz", - "integrity": "sha512-NXXogbAxVlVje4XHX+Cx5eMFZv4Dho/2rIcdBHg9CNPFUGZdM4cRdgIgM7USmNYsC12XY0bZENEQ+KBk72fl+A==", + "version": "13.12.0", + "resolved": "https://registry.npmjs.org/cypress/-/cypress-13.12.0.tgz", + "integrity": "sha512-udzS2JilmI9ApO/UuqurEwOvThclin5ntz7K0BtnHBs+tg2Bl9QShLISXpSEMDv/u8b6mqdoAdyKeZiSqKWL8g==", "dev": true, "hasInstallScript": true, "dependencies": { @@ -12526,6 +12639,22 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/date-fns": { + "version": "2.30.0", + "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.30.0.tgz", + "integrity": "sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw==", + "dev": true, + "dependencies": { + "@babel/runtime": "^7.21.0" + }, + "engines": { + "node": ">=0.11" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/date-fns" + } + }, "node_modules/date-now": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", @@ -23915,6 +24044,12 @@ "memory-pager": "^1.0.2" } }, + "node_modules/spawn-command": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/spawn-command/-/spawn-command-0.0.2.tgz", + "integrity": "sha512-zC8zGoGkmc8J9ndvml8Xksr1Amk9qBujgbF0JAIWO7kXr43w0h/0GJNM/Vustixu+YE8N/MTrQ7N31FvHUACxQ==", + "dev": true + }, "node_modules/spawn-please": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/spawn-please/-/spawn-please-1.0.0.tgz", @@ -24874,6 +25009,15 @@ "tslib": "2" } }, + "node_modules/tree-kill": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", + "integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==", + "dev": true, + "bin": { + "tree-kill": "cli.js" + } + }, "node_modules/ts-api-utils": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.3.0.tgz", diff --git a/package.json b/package.json index 29be1fbd57..89515be01e 100644 --- a/package.json +++ b/package.json @@ -100,6 +100,8 @@ "@typescript-eslint/parser": "^6.0.0", "@vitest/coverage-v8": "^1.3.1", "babel-plugin-import": "^1.13.6", + "concurrently": "^8.2.2", + "cypress": "^13.12.0", "depcheck": "^1.4.7", "eslint": "^8.55.0", "eslint-config-prettier": "^8.5.0", From 7b1b92bf702750593ad6924feea3ef86ef70b0f3 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Mon, 1 Jul 2024 15:08:47 +0100 Subject: [PATCH 20/72] fix cypress workflow trigger --- .github/workflows/cypress.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 9ba85fc433..13794cf0fd 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -9,7 +9,7 @@ on: - 'demos/**' - 'dev/**' - 'contracts/**' - - '.github/workflows/tests.yml' + - '.github/workflows/cypress.yml' workflow_dispatch: concurrency: From 52df9ae7cd23da15d22d119c02a269bc2517adf5 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Mon, 1 Jul 2024 15:09:37 +0100 Subject: [PATCH 21/72] fix cypress workflow branch triggers --- .github/workflows/cypress.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 13794cf0fd..5438ebd7e9 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -2,7 +2,7 @@ name: cypress on: pull_request: - branches: [main] + branches: [main, dev, release/*] paths: - 'docker/**' - 'packages/**' From ca30c6d6e9f2adfcd97fdfd091758f9fff890908 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Mon, 1 Jul 2024 15:23:23 +0100 Subject: [PATCH 22/72] fix rust file triggers --- .github/workflows/clippy.yml | 2 +- .github/workflows/rustfmt.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml index cf236b2e57..be2ecc05ff 100644 --- a/.github/workflows/clippy.yml +++ b/.github/workflows/clippy.yml @@ -4,7 +4,7 @@ on: pull_request: branches: [main, dev, release/*] paths: - - '**.rs' + - 'protocol/**' - '.github/workflows/clippy.yml' workflow_dispatch: diff --git a/.github/workflows/rustfmt.yml b/.github/workflows/rustfmt.yml index 7ea2dbc6f1..4aaa436492 100644 --- a/.github/workflows/rustfmt.yml +++ b/.github/workflows/rustfmt.yml @@ -4,7 +4,7 @@ on: pull_request: branches: [main, dev, release/*] paths: - - '**.rs' + - 'protocol/**' - '.github/workflows/rustfmt.yml' workflow_dispatch: From 0c437362af20a1e2f24ff7aa6be2d5c92fc4dd04 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Mon, 1 Jul 2024 15:23:41 +0100 Subject: [PATCH 23/72] move webpack bundling check to tests workflow --- .github/workflows/tests.yml | 5 ++ .github/workflows/webpack_bundling.yml | 99 -------------------------- 2 files changed, 5 insertions(+), 99 deletions(-) delete mode 100644 .github/workflows/webpack_bundling.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1e90937b6e..4f17c8dfa0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -96,6 +96,11 @@ jobs: - run: npm run build:all - run: npm run build:all:cjs + # bundle procaptcha-bundle using webpack + - name: Webpack Bundle procaptcha-bundle + run: | + npm run -w @prosopo/procaptcha-bundle bundle:dev:webpack + - name: Setup env run: | cp demos/client-example-server/env.development demos/client-example-server/.env.test diff --git a/.github/workflows/webpack_bundling.yml b/.github/workflows/webpack_bundling.yml deleted file mode 100644 index f3e514f7ec..0000000000 --- a/.github/workflows/webpack_bundling.yml +++ /dev/null @@ -1,99 +0,0 @@ -name: webpack_bundling - -on: - pull_request: - branches: [main, dev, release/*] - paths: - - 'src/**' - - 'package.json' - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -env: - CARGO_TERM_COLOR: always - GH_TOKEN: ${{ github.token }} - NODE_ENV: test - -jobs: - check: - runs-on: ubuntu-latest - 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 "******************************" - # Checkout the repo - - 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 }}- - - - uses: actions/setup-node@v3 - with: - node-version-file: '.nvmrc' - - name: Install npm - run: npm i -g npm@$(cat package.json | jq -r .engines.npm) - - - run: npm install - - # build all packages in workspace - - run: npm run build scripts - - run: npm run build:all:cjs - - # bundle procaptcha-bundle using webpack - - name: Webpack Bundle procaptcha-bundle - run: | - npm run -w @prosopo/procaptcha-bundle bundle:dev:webpack From 1be682a943e732880a02e7147fc6d85a8aec276e Mon Sep 17 00:00:00 2001 From: George Oastler Date: Mon, 1 Jul 2024 15:23:52 +0100 Subject: [PATCH 24/72] remove typechain version check --- .github/workflows/tests_protocol.yml | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/.github/workflows/tests_protocol.yml b/.github/workflows/tests_protocol.yml index 2a80d45f5b..f2ab840d59 100644 --- a/.github/workflows/tests_protocol.yml +++ b/.github/workflows/tests_protocol.yml @@ -94,30 +94,6 @@ jobs: cd protocol/dev npm run cli -- build --docker --skip-env - - name: Check typechain is up-to-date - run: | - # check the output of typechain has a contract hash matching the current contract version - # this looks at the hash in the metadata for the contracts and matches typechain's metadata hash against protocol's metadata hash to detect differences - set -euo pipefail - typechain_contracts=$(find ./contracts -maxdepth 1 -mindepth 1 -type d) - protocol_contracts=$(find ./protocol/target/ink -maxdepth 1 -mindepth 1 -type d) - contracts=( "${typechain_contracts[@]}" "${protocol_contracts[@]}" ) - for contract_path in ${contracts[@]}; do - contract_name=$(basename $contract_path) - typechain_metadata="./contracts/$contract_name/src/$contract_name.json" - protocol_metadata="./protocol/target/ink/$contract_name/$contract_name.json" - typechain_hash=$(cat $typechain_metadata | jq -r '.source.hash') - protocol_hash=$(cat $protocol_metadata | jq -r '.source.hash') - if [ "$typechain_hash" != "$protocol_hash" ]; then - echo "Hash mismatch for $contract_name" - echo "Typechain: $typechain_hash" - echo "Protocol: $protocol_hash" - exit 1 - else - echo "Hash match for $contract_path" - fi - done - - name: Test contracts run: | cd protocol/dev From 16474dc7cc943d8dbf560c97c2a25f0f4e649c2a Mon Sep 17 00:00:00 2001 From: George Oastler Date: Mon, 1 Jul 2024 15:25:36 +0100 Subject: [PATCH 25/72] rename workflows --- .github/workflows/{clippy.yml => protocol_clippy.yml} | 4 ++-- .github/workflows/{rustfmt.yml => protocol_rustfmt.yml} | 4 ++-- .github/workflows/{tests_protocol.yml => protocol_tests.yml} | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) rename .github/workflows/{clippy.yml => protocol_clippy.yml} (98%) rename .github/workflows/{rustfmt.yml => protocol_rustfmt.yml} (98%) rename .github/workflows/{tests_protocol.yml => protocol_tests.yml} (98%) diff --git a/.github/workflows/clippy.yml b/.github/workflows/protocol_clippy.yml similarity index 98% rename from .github/workflows/clippy.yml rename to .github/workflows/protocol_clippy.yml index be2ecc05ff..9ef4a07e87 100644 --- a/.github/workflows/clippy.yml +++ b/.github/workflows/protocol_clippy.yml @@ -1,11 +1,11 @@ -name: clippy +name: protocol_clippy on: pull_request: branches: [main, dev, release/*] paths: - 'protocol/**' - - '.github/workflows/clippy.yml' + - '.github/workflows/protocol_clippy.yml' workflow_dispatch: concurrency: diff --git a/.github/workflows/rustfmt.yml b/.github/workflows/protocol_rustfmt.yml similarity index 98% rename from .github/workflows/rustfmt.yml rename to .github/workflows/protocol_rustfmt.yml index 4aaa436492..a1f356de58 100644 --- a/.github/workflows/rustfmt.yml +++ b/.github/workflows/protocol_rustfmt.yml @@ -1,11 +1,11 @@ -name: rustfmt +name: protocol_rustfmt on: pull_request: branches: [main, dev, release/*] paths: - 'protocol/**' - - '.github/workflows/rustfmt.yml' + - '.github/workflows/protocol_rustfmt.yml' workflow_dispatch: concurrency: diff --git a/.github/workflows/tests_protocol.yml b/.github/workflows/protocol_tests.yml similarity index 98% rename from .github/workflows/tests_protocol.yml rename to .github/workflows/protocol_tests.yml index f2ab840d59..2bb8f34d4c 100644 --- a/.github/workflows/tests_protocol.yml +++ b/.github/workflows/protocol_tests.yml @@ -1,11 +1,11 @@ -name: tests_protocol +name: protocol_tests on: pull_request: branches: [main, dev, release/*] paths: - 'protocol/**' - - '.github/workflows/tests_protocol.yml' + - '.github/workflows/protocol_tests.yml' workflow_dispatch: concurrency: From b3705570416ccecfbc216da6d01110305cbae387 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Mon, 1 Jul 2024 17:22:31 +0100 Subject: [PATCH 26/72] make the github actions cache include the branch name --- .github/workflows/bump_version.yml | 2 +- .github/workflows/cache.yml | 9 ++++----- .github/workflows/cypress.yml | 2 +- .github/workflows/lint.yml | 2 +- .github/workflows/ls_cache.yml | 2 +- .github/workflows/protocol_clippy.yml | 2 +- .github/workflows/protocol_rustfmt.yml | 2 +- .github/workflows/protocol_tests.yml | 2 +- .github/workflows/provider_image.yml | 2 +- .github/workflows/tests.yml | 2 +- 10 files changed, 13 insertions(+), 14 deletions(-) diff --git a/.github/workflows/bump_version.yml b/.github/workflows/bump_version.yml index 69a183e4f1..76b0e3288d 100644 --- a/.github/workflows/bump_version.yml +++ b/.github/workflows/bump_version.yml @@ -75,7 +75,7 @@ jobs: # 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 }}- + project-cache-${{ github.event.pull_request.head.ref || github.ref }}-${{ runner.os }}-${{ runner.arch }}- - run: ls -la ~/.cache/Cypress || true - run: ls -la protocol/cargo-cache || true diff --git a/.github/workflows/cache.yml b/.github/workflows/cache.yml index 904ba7a39c..0ab150b741 100644 --- a/.github/workflows/cache.yml +++ b/.github/workflows/cache.yml @@ -4,7 +4,7 @@ name: post_pr # we do this because any branch can use caches built on dev, 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: @@ -117,20 +117,19 @@ 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 +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 diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 5438ebd7e9..1b6fb178d5 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -83,7 +83,7 @@ jobs: # 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 }}- + project-cache-${{ github.event.pull_request.head.ref || github.ref }}-${{ runner.os }}-${{ runner.arch }}- - uses: actions/setup-node@v3 with: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 2c2b697f06..75fd2f518d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -77,7 +77,7 @@ jobs: # 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 }}- + project-cache-${{ github.event.pull_request.head.ref || github.ref }}-${{ runner.os }}-${{ runner.arch }}- - uses: actions/setup-node@v3 with: diff --git a/.github/workflows/ls_cache.yml b/.github/workflows/ls_cache.yml index 65fed666a5..4f8ff5a569 100644 --- a/.github/workflows/ls_cache.yml +++ b/.github/workflows/ls_cache.yml @@ -73,7 +73,7 @@ jobs: # 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 }}- + project-cache-${{ github.event.pull_request.head.ref || github.ref }}-${{ runner.os }}-${{ runner.arch }}- - run: ls -la ~/.cache/Cypress || true - run: ls -la protocol/cargo-cache || true diff --git a/.github/workflows/protocol_clippy.yml b/.github/workflows/protocol_clippy.yml index 9ef4a07e87..2e615ac533 100644 --- a/.github/workflows/protocol_clippy.yml +++ b/.github/workflows/protocol_clippy.yml @@ -79,7 +79,7 @@ jobs: # 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 }}- + project-cache-${{ github.event.pull_request.head.ref || github.ref }}-${{ runner.os }}-${{ runner.arch }}- - uses: actions/setup-node@v3 with: diff --git a/.github/workflows/protocol_rustfmt.yml b/.github/workflows/protocol_rustfmt.yml index a1f356de58..052693c873 100644 --- a/.github/workflows/protocol_rustfmt.yml +++ b/.github/workflows/protocol_rustfmt.yml @@ -79,7 +79,7 @@ jobs: # 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 }}- + project-cache-${{ github.event.pull_request.head.ref || github.ref }}-${{ runner.os }}-${{ runner.arch }}- - uses: actions/setup-node@v3 with: diff --git a/.github/workflows/protocol_tests.yml b/.github/workflows/protocol_tests.yml index 2bb8f34d4c..1e1e6b410c 100644 --- a/.github/workflows/protocol_tests.yml +++ b/.github/workflows/protocol_tests.yml @@ -79,7 +79,7 @@ jobs: # 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 }}- + project-cache-${{ github.event.pull_request.head.ref || github.ref }}-${{ runner.os }}-${{ runner.arch }}- - uses: actions/setup-node@v3 with: diff --git a/.github/workflows/provider_image.yml b/.github/workflows/provider_image.yml index 370d8fe5a4..e35fb3c6d8 100644 --- a/.github/workflows/provider_image.yml +++ b/.github/workflows/provider_image.yml @@ -81,7 +81,7 @@ jobs: # 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 }}- + project-cache-${{ github.event.pull_request.head.ref || github.ref }}-${{ runner.os }}-${{ runner.arch }}- - uses: actions/setup-node@v3 with: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4f17c8dfa0..8c5a80db92 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -83,7 +83,7 @@ jobs: # 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 }}- + project-cache-${{ github.event.pull_request.head.ref || github.ref }}-${{ runner.os }}-${{ runner.arch }}- - uses: actions/setup-node@v3 with: From 88e5c18dcc9d002e036297963556eef225969c14 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Mon, 1 Jul 2024 17:24:44 +0100 Subject: [PATCH 27/72] publish on push to main --- .github/workflows/publish.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 00f5396c6b..0a020f4803 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -5,9 +5,6 @@ on: # only on the main branch branches: - main - paths: - # only when the package.json file changes - - 'package.json' jobs: publish: From 178d62f9656adce10f90e7427964c5bae81835d3 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Mon, 1 Jul 2024 17:33:33 +0100 Subject: [PATCH 28/72] add js bundle test step --- .github/workflows/tests.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8c5a80db92..d2f1ebe7fa 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -101,6 +101,18 @@ jobs: run: | npm run -w @prosopo/procaptcha-bundle bundle:dev:webpack + - name: Build JS bundle + run: | + # Copy the rococo env file to production env file + echo "Copying the rococo env to production env file in procaptcha-bundle" + cp ./dev/scripts/env.production ./packages/procaptcha-bundle/.env.production + + # Navigate to the JS bundle directory and build + echo "Navigating to 'packages/procaptcha-bundle' and building JS bundle..." + cd packages/procaptcha-bundle + + NODE_ENV=production npm run bundle:prod + - name: Setup env run: | cp demos/client-example-server/env.development demos/client-example-server/.env.test From e7a690b4989f54dd2cdedb488557f3e5067b12be Mon Sep 17 00:00:00 2001 From: George Oastler Date: Tue, 2 Jul 2024 11:12:49 +0100 Subject: [PATCH 29/72] workflow for ensuring all versions move in lockstep --- .github/workflows/lockstep_version.yml | 83 ++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 .github/workflows/lockstep_version.yml diff --git a/.github/workflows/lockstep_version.yml b/.github/workflows/lockstep_version.yml new file mode 100644 index 0000000000..dd76a9291a --- /dev/null +++ b/.github/workflows/lockstep_version.yml @@ -0,0 +1,83 @@ +name: lockstep_version + +on: + pull_request: + branches: [main] + paths: + - '**/package.json' + - '**/Cargo.toml' + - '.github/workflows/lockstep_version.yml' + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always + ENVIRONMENT: development + GH_TOKEN: ${{ github.token }} + +jobs: + check: + runs-on: ubuntu-latest + 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 + + - name: Check package versions are all moving in lockstep + run: | + set -eu + # find all package.json files, recursively + pkgJsons=$(find . -name package.json -prune -not -path '*/node_modules/*' -not -path '*/.next/*') + # extract version from package.json files + jsVers=$(xargs -I % sh -c "jq -r '.version' %" <<< "$pkgJsons") + + # find all Cargo.toml files + cargoTomls=$(find . -name Cargo.toml -prune -not -path '*/protocol/cargo-cache/*') + # extract the version out of all Cargo.toml files (we're assuming the version is the first version line encountered) + rustVers=$(xargs -I % sh -c "grep -m 1 'version' % | awk -F'\"' '{print \$2}'" <<< "$cargoTomls") + + # compare all versions detected, if they are not all the same, fail the workflow + vers=$(echo "$jsVers $rustVers" | tr ' ' '\n') + if [[ $(echo "$vers" | uniq | wc -l) -ne 1 ]]; then + echo "versions are not all the same: $vers" + exit 1 + fi From e719b9dc1066116a9a91d4c58f5130ea026a2f61 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Tue, 2 Jul 2024 11:23:06 +0100 Subject: [PATCH 30/72] blurb for each workflow --- .github/workflows/auto_merge.yml | 2 ++ .github/workflows/bump_version.yml | 2 ++ .github/workflows/cache.yml | 2 ++ .github/workflows/consistent_workflow_names.yml | 2 ++ .github/workflows/contract_version.yml | 2 ++ .github/workflows/cypress.yml | 2 ++ .github/workflows/dependent_issues.yml | 2 ++ .github/workflows/lint.yml | 2 ++ .github/workflows/lockstep_version.yml | 4 ++++ .github/workflows/ls_cache.yml | 2 ++ .github/workflows/prosoponator_bot.yml | 2 ++ .github/workflows/protocol_clippy.yml | 2 ++ .github/workflows/protocol_rustfmt.yml | 2 ++ .github/workflows/protocol_tests.yml | 2 ++ .github/workflows/provider_image.yml | 2 ++ .github/workflows/publish.yml | 2 ++ .github/workflows/tests.yml | 2 ++ 17 files changed, 36 insertions(+) diff --git a/.github/workflows/auto_merge.yml b/.github/workflows/auto_merge.yml index a14aba39de..7ba211fa75 100644 --- a/.github/workflows/auto_merge.yml +++ b/.github/workflows/auto_merge.yml @@ -1,3 +1,5 @@ +# Merge a PR automatically when opened or reopened + name: auto_merge on: diff --git a/.github/workflows/bump_version.yml b/.github/workflows/bump_version.yml index 76b0e3288d..b84670234c 100644 --- a/.github/workflows/bump_version.yml +++ b/.github/workflows/bump_version.yml @@ -1,3 +1,5 @@ +# Workflow which bumps the version of all packages in the repo + name: bump_version on: diff --git a/.github/workflows/cache.yml b/.github/workflows/cache.yml index 0ab150b741..5fb82f71a4 100644 --- a/.github/workflows/cache.yml +++ b/.github/workflows/cache.yml @@ -1,3 +1,5 @@ +# Build a cache of build artifacts after PRs to speed up subsequent builds + name: post_pr # on push to main, or manually triggered diff --git a/.github/workflows/consistent_workflow_names.yml b/.github/workflows/consistent_workflow_names.yml index a67d780027..f67feb12cb 100644 --- a/.github/workflows/consistent_workflow_names.yml +++ b/.github/workflows/consistent_workflow_names.yml @@ -1,3 +1,5 @@ +# Check workflow names are consistent with their filenames for easier debugging + name: consistent_workflow_names on: diff --git a/.github/workflows/contract_version.yml b/.github/workflows/contract_version.yml index 8e7d5d371e..5896529591 100644 --- a/.github/workflows/contract_version.yml +++ b/.github/workflows/contract_version.yml @@ -1,3 +1,5 @@ +# Check the contract JS is in sync with the Rust version + name: contract_version on: diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 1b6fb178d5..30455ceaae 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -1,3 +1,5 @@ +# Run cypress tests + name: cypress on: diff --git a/.github/workflows/dependent_issues.yml b/.github/workflows/dependent_issues.yml index 12500011aa..838cea55d6 100644 --- a/.github/workflows/dependent_issues.yml +++ b/.github/workflows/dependent_issues.yml @@ -1,3 +1,5 @@ +# Check for dependent issues and pull requests in GitHub repositories. + name: dependent_issues on: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 75fd2f518d..a2e72a2c39 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,3 +1,5 @@ +# Lint the codebase + name: lint on: diff --git a/.github/workflows/lockstep_version.yml b/.github/workflows/lockstep_version.yml index dd76a9291a..e5493eeb24 100644 --- a/.github/workflows/lockstep_version.yml +++ b/.github/workflows/lockstep_version.yml @@ -1,3 +1,7 @@ +# Workflow to check all versions of packages are the same, ensuring we move in lockstep. +# We made the decision to move in lockstep for greater dev speed at the detriment of more frequent version bumps than necessary to some packages. +# Lockstep versioning is simpler and doesn't require backwards compatibility headaches. + name: lockstep_version on: diff --git a/.github/workflows/ls_cache.yml b/.github/workflows/ls_cache.yml index 4f8ff5a569..c3e63d5429 100644 --- a/.github/workflows/ls_cache.yml +++ b/.github/workflows/ls_cache.yml @@ -1,3 +1,5 @@ +# This workflow will list the contents of the cache directories, useful for debugging cache issues. + name: ls_cache on: diff --git a/.github/workflows/prosoponator_bot.yml b/.github/workflows/prosoponator_bot.yml index d8486fced7..8f647257cf 100644 --- a/.github/workflows/prosoponator_bot.yml +++ b/.github/workflows/prosoponator_bot.yml @@ -1,3 +1,5 @@ +# Run prosoponator bot on any comments + name: prosoponator_bot on: issue_comment diff --git a/.github/workflows/protocol_clippy.yml b/.github/workflows/protocol_clippy.yml index 2e615ac533..2267c17cb1 100644 --- a/.github/workflows/protocol_clippy.yml +++ b/.github/workflows/protocol_clippy.yml @@ -1,3 +1,5 @@ +# This workflow will run clippy on the protocol workspace + name: protocol_clippy on: diff --git a/.github/workflows/protocol_rustfmt.yml b/.github/workflows/protocol_rustfmt.yml index 052693c873..8196952d2f 100644 --- a/.github/workflows/protocol_rustfmt.yml +++ b/.github/workflows/protocol_rustfmt.yml @@ -1,3 +1,5 @@ +# This workflow will run rustfmt on the protocol workspace + name: protocol_rustfmt on: diff --git a/.github/workflows/protocol_tests.yml b/.github/workflows/protocol_tests.yml index 1e1e6b410c..39b19421e5 100644 --- a/.github/workflows/protocol_tests.yml +++ b/.github/workflows/protocol_tests.yml @@ -1,3 +1,5 @@ +# Run the protocol workspace tests + name: protocol_tests on: diff --git a/.github/workflows/provider_image.yml b/.github/workflows/provider_image.yml index e35fb3c6d8..2be03cf88b 100644 --- a/.github/workflows/provider_image.yml +++ b/.github/workflows/provider_image.yml @@ -1,3 +1,5 @@ +# Build and publish the provider image + name: provider_image on: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 0a020f4803..2204060099 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,3 +1,5 @@ +# Publish packages after a release + name: publish on: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d2f1ebe7fa..8489333890 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,3 +1,5 @@ +# Run tests for js packages + name: tests on: From e77616c01bce3ea9844505416a3ca7b831bc7c69 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Tue, 2 Jul 2024 11:35:35 +0100 Subject: [PATCH 31/72] dockerhub login check for before a release --- .github/workflows/dockerhub_login.yml | 65 +++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/workflows/dockerhub_login.yml diff --git a/.github/workflows/dockerhub_login.yml b/.github/workflows/dockerhub_login.yml new file mode 100644 index 0000000000..51bc5c8bbe --- /dev/null +++ b/.github/workflows/dockerhub_login.yml @@ -0,0 +1,65 @@ +# Test login to dockerhub. This is required for publishing to work, so this tests the login ahead of time. + +name: dockerhub_login + +on: + pull_request: + branches: [release/*] + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always + ENVIRONMENT: development + GH_TOKEN: ${{ github.token }} + +jobs: + check: + name: check + runs-on: ubuntu-latest + 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 "******************************" + + - name: Dockerhub login + run: | + echo "Logging into Docker Hub." + echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin 2> /dev/null From f08361d154cacf4c10c04969722fa1197e7cea74 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Tue, 2 Jul 2024 11:38:31 +0100 Subject: [PATCH 32/72] rename publish to release --- .../workflows/{publish.yml => release.yml} | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) rename .github/workflows/{publish.yml => release.yml} (96%) diff --git a/.github/workflows/publish.yml b/.github/workflows/release.yml similarity index 96% rename from .github/workflows/publish.yml rename to .github/workflows/release.yml index 2204060099..07d8160e78 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/release.yml @@ -1,12 +1,11 @@ -# Publish packages after a release +# Publish + deploy packages after a release -name: publish +name: release on: push: # only on the main branch - branches: - - main + branches: [ release/* ] jobs: publish: @@ -64,7 +63,19 @@ jobs: id: next_version run: | - VERSION=$(cat package.json | jq -r '.version' || echo "0.0.0") + VERSION=$(cat package.json | jq -r '.version') + + # if version not detected, error + if [[ -z "$VERSION" ]]; then + echo "Failed to get version" + exit 1 + fi + # or if version null + if [[ "$VERSION" == "null" ]]; then + echo "Failed to get version" + exit 1 + fi + # split into major, minor, patch MAJOR=$(echo $VERSION | cut -d. -f1) MINOR=$(echo $VERSION | cut -d. -f2) From 36e8425e9bb4bcb2cba71ca1cbfb578415e2f35b Mon Sep 17 00:00:00 2001 From: George Oastler Date: Tue, 2 Jul 2024 11:38:41 +0100 Subject: [PATCH 33/72] remove typedoc step --- .github/workflows/release.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 07d8160e78..5d97507367 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -113,10 +113,6 @@ jobs: npm run cli -- clean --docker npm run cli -- build --docker --release - - name: Typedoc - run: | - npm run docs - - name: Build JS bundle run: | # Copy the rococo env file to production env file From 0bb289b51592a775e3b2df7c4ad2a970132eae84 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Tue, 2 Jul 2024 11:42:43 +0100 Subject: [PATCH 34/72] standardise step ids in release workflow --- .github/workflows/release.yml | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5d97507367..8bff4ba7a7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -187,7 +187,7 @@ jobs: - name: Github release continue-on-error: true - id: publish_github + id: github_release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -197,10 +197,10 @@ jobs: - name: Github release notification if: always() run: | - if [[ "${{ steps.publish_github.outcome }}" == 'success' ]]; then + if [[ "${{ steps.github_release.outcome }}" == 'success' ]]; then echo "Github release successful." curl -X POST -H 'Content-type: application/json' --data "{\"text\":\":check-passed: Github release has been published.\"}" ${{ secrets.SLACKBOT_DEVOPS }} - elif [[ "${{ steps.publish_github.outcome }}" == 'failure' ]]; then + elif [[ "${{ steps.github_release.outcome }}" == 'failure' ]]; then echo "Github release failed." curl -X POST -H 'Content-type: application/json' --data "{\"text\":\":check-failed: Github release <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|v${{ steps.next_version.outputs.version }}> failed.\"}" ${{ secrets.SLACKBOT_DEVOPS }} else @@ -209,7 +209,7 @@ jobs: - name: Npm release continue-on-error: true - id: publish_release + id: npm_release run: | if [[ "${{ vars.HOST_GITHUB_ACTIONS }}" == true ]]; then echo "Running on GitHub Actions" @@ -226,10 +226,10 @@ jobs: - name: Npm release notification if: always() run: | - if [[ "${{ steps.publish_release.outcome }}" == 'success' ]]; then + if [[ "${{ steps.npm_release.outcome }}" == 'success' ]]; then echo "Npm release successful." curl -X POST -H 'Content-type: application/json' --data "{\"text\":\":check-passed: Npm release has been published.\"}" ${{ secrets.SLACKBOT_DEVOPS }} - elif [[ "${{ steps.publish_release.outcome }}" == 'failure' ]]; then + elif [[ "${{ steps.npm_release.outcome }}" == 'failure' ]]; then echo "Npm release failed." curl -X POST -H 'Content-type: application/json' --data "{\"text\":\":check-failed: Npm release <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|v${{ steps.next_version.outputs.version }}> failed.\"}" ${{ secrets.SLACKBOT_DEVOPS }} else @@ -238,7 +238,7 @@ jobs: - name: Docker js_server release continue-on-error: true - id: publish_docker_js_server + id: docker_js_server_release run: | # Push the new image to Docker Hub echo "Pushing Docker image..." @@ -251,10 +251,10 @@ jobs: - name: Docker js_server release notification if: always() run: | - if [[ "${{ steps.publish_docker_js_server.outcome }}" == 'success' ]]; then + if [[ "${{ steps.docker_js_server_release.outcome }}" == 'success' ]]; then echo "Docker js_server release successful." curl -X POST -H 'Content-type: application/json' --data "{\"text\":\":check-passed: Docker js_server release has been published.\"}" ${{ secrets.SLACKBOT_DEVOPS }} - elif [[ "${{ steps.publish_docker_js_server.outcome }}" == 'failure' ]]; then + elif [[ "${{ steps.docker_js_server_release.outcome }}" == 'failure' ]]; then echo "Docker js_server release failed." curl -X POST -H 'Content-type: application/json' --data "{\"text\":\":check-failed: Docker js_server release <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|v${{ steps.next_version.outputs.version }}> failed.\"}" ${{ secrets.SLACKBOT_DEVOPS }} else @@ -262,14 +262,14 @@ jobs: fi - name: Redeploy flux docker js_server - id: redeploy_flux_docker_js_server + id: flux_docker_js_server_redeploy continue-on-error: true if: always() env: PROSOPO_ZELCORE_PRIVATE_KEY: ${{ secrets.PROSOPO_ZELCORE_PRIVATE_KEY }} PROSOPO_ZELCORE_PUBLIC_KEY: ${{ secrets.PROSOPO_ZELCORE_PUBLIC_KEY }} run: | - if [[ "${{ steps.publish_docker_js_server.outcome }}" == 'success' ]]; then + if [[ "${{ steps.docker_js_server_release.outcome }}" == 'success' ]]; then echo "Installing @prosopo/flux..." npm i -g @prosopo/flux echo "Soft redeploying flux docker js_server." @@ -284,11 +284,11 @@ jobs: PROSOPO_ZELCORE_PRIVATE_KEY: ${{ secrets.PROSOPO_ZELCORE_PRIVATE_KEY }} PROSOPO_ZELCORE_PUBLIC_KEY: ${{ secrets.PROSOPO_ZELCORE_PUBLIC_KEY }} run: | - if [[ "${{ steps.publish_docker_js_server.outcome }}" == 'success' ]]; then - if [[ "${{ steps.redeploy_flux_docker_js_server.outcome }}" == 'success' ]]; then + if [[ "${{ steps.docker_js_server_release.outcome }}" == 'success' ]]; then + if [[ "${{ steps.flux_docker_js_server_redeploy.outcome }}" == 'success' ]]; then echo "Redeployed flux docker js_server." curl -X POST -H 'Content-type: application/json' --data "{\"text\":\":check-passed: Flux docker js_server redeploy <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|v${{ steps.next_version.outputs.version }}> has been requested.\"}" ${{ secrets.SLACKBOT_DEVOPS }} - elif [[ "${{ steps.redeploy_flux_docker_js_server.outcome }}" == 'failure' ]]; then + elif [[ "${{ steps.flux_docker_js_server_redeploy.outcome }}" == 'failure' ]]; then echo "Redeploying flux docker js_server failed." curl -X POST -H 'Content-type: application/json' --data "{\"text\":\":check-failed: Flux docker js_server redeploy <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|v${{ steps.next_version.outputs.version }}> failed.\"}" ${{ secrets.SLACKBOT_DEVOPS }} else @@ -324,7 +324,7 @@ jobs: cd ../.. - name: Build and push the Provider Container - id: publish_docker_provider + id: docker_provider_release continue-on-error: true uses: docker/build-push-action@v5 with: @@ -337,10 +337,10 @@ jobs: - name: Docker provider release notification if: always() run: | - if [[ "${{ steps.publish_docker_provider.outcome }}" == 'success' ]]; then + if [[ "${{ steps.docker_provider_release.outcome }}" == 'success' ]]; then echo "Docker provider release successful." curl -X POST -H 'Content-type: application/json' --data "{\"text\":\":check-passed: Docker provider release has been published.\"}" ${{ secrets.SLACKBOT_DEVOPS }} - elif [[ "${{ steps.publish_docker_provider.outcome }}" == 'failure' ]]; then + elif [[ "${{ steps.docker_provider_release.outcome }}" == 'failure' ]]; then echo "Docker provider release failed." curl -X POST -H 'Content-type: application/json' --data "{\"text\":\":check-failed: Docker provider release <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|v${{ steps.next_version.outputs.version }}> failed.\"}" ${{ secrets.SLACKBOT_DEVOPS }} else From d1c6e5a37905aa581f77241869f71ae0a9399ce5 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Tue, 2 Jul 2024 12:10:20 +0100 Subject: [PATCH 35/72] dummy version bump --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 89515be01e..4245948f0f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@prosopo/captcha", - "version": "1.0.2", + "version": "1.3.2", "stableVersion": "0.0.0", "author": "Prosopo", "type": "module", From 95acebe5696dd1abe7b243d0cfdeec6a2b1fd574 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Tue, 2 Jul 2024 12:13:24 +0100 Subject: [PATCH 36/72] Delete dockerhub_login.yml --- .github/workflows/dockerhub_login.yml | 65 --------------------------- 1 file changed, 65 deletions(-) delete mode 100644 .github/workflows/dockerhub_login.yml diff --git a/.github/workflows/dockerhub_login.yml b/.github/workflows/dockerhub_login.yml deleted file mode 100644 index 51bc5c8bbe..0000000000 --- a/.github/workflows/dockerhub_login.yml +++ /dev/null @@ -1,65 +0,0 @@ -# Test login to dockerhub. This is required for publishing to work, so this tests the login ahead of time. - -name: dockerhub_login - -on: - pull_request: - branches: [release/*] - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -env: - CARGO_TERM_COLOR: always - ENVIRONMENT: development - GH_TOKEN: ${{ github.token }} - -jobs: - check: - name: check - runs-on: ubuntu-latest - 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 "******************************" - - - name: Dockerhub login - run: | - echo "Logging into Docker Hub." - echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin 2> /dev/null From a88de414aa368bed536467e89693a5ffdbada56d Mon Sep 17 00:00:00 2001 From: George Oastler Date: Tue, 2 Jul 2024 12:13:36 +0100 Subject: [PATCH 37/72] release version check --- .github/workflows/release_version.yml | 115 ++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 .github/workflows/release_version.yml diff --git a/.github/workflows/release_version.yml b/.github/workflows/release_version.yml new file mode 100644 index 0000000000..f36476c400 --- /dev/null +++ b/.github/workflows/release_version.yml @@ -0,0 +1,115 @@ +# Check the version has been bumped before releasing + +name: release_version + +on: + pull_request: + branches: [release/*] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + check: + runs-on: ubuntu-latest + 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 + id: next_version + run: | + + # use git to look for differences in the root package.json between the before and after state + # before and after git sha's are passed in as env vars by github + diff=$(git show --pretty=format: --no-notes ${{ github.event.before }}..${{ github.event.after }} -- package.json | cat) + echo "diff:" + echo "$diff" + echo "" + + # grep for the version line + # next version will be the line added + next=$(echo "$diff" | grep -e "\+\s*\"version\"") + # previous version will be the line removed + prev=$(echo "$diff" | grep -e "-\s*\"version\"") + echo "version_changes:" + echo "$version_changes" + echo "" + + # if the version line has changed then we know there's been a version change. Not necessarily bumped up, though! + # the next version will be whatever is currently in the package.json file + # subsequent steps can choose whether the version has been bumped or not. All we know at this stage is the version has been changed, i.e. new_version != old_version, but we don't know whether new_version > old_version or new_version < old_version + if [[ -n "$version_changes" ]]; then + echo "version has changed" + else + echo "version has not changed" + exit 1 + fi + + NEXT_VERSION=$(cat package.json | jq -r '.version' || echo "0.0.0") + # split into major, minor, patch + NEXT_MAJOR=$(echo $NEXT_VERSION | cut -d. -f1) + NEXT_MINOR=$(echo $NEXT_VERSION | cut -d. -f2) + NEXT_PATCH=$(echo $NEXT_VERSION | cut -d. -f3) + echo "next_version=$NEXT_VERSION" + echo "next_major=$MAJOR" + echo "next_minor=$MINOR" + echo "next_patch=$PATCH" + + # export the next version numbers + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "major=$MAJOR" >> $GITHUB_OUTPUT + echo "minor=$MINOR" >> $GITHUB_OUTPUT + echo "patch=$PATCH" >> $GITHUB_OUTPUT + + - name: Check version has been bumped + run: | + set -eu + # get the previous version + # break into major, minor, patch + + # get the current version + # break into major, minor, patch + + # check if the current version is greater than the previous version + From fdcf40ee26eff37c636f0e2483851704d5e6cd59 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Tue, 2 Jul 2024 12:22:24 +0100 Subject: [PATCH 38/72] workflow to check for valid version bumps --- .github/workflows/release_version.yml | 76 ++++++++++----------------- 1 file changed, 27 insertions(+), 49 deletions(-) diff --git a/.github/workflows/release_version.yml b/.github/workflows/release_version.yml index f36476c400..77a7364b8d 100644 --- a/.github/workflows/release_version.yml +++ b/.github/workflows/release_version.yml @@ -57,59 +57,37 @@ jobs: # 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 - id: next_version run: | - # use git to look for differences in the root package.json between the before and after state - # before and after git sha's are passed in as env vars by github - diff=$(git show --pretty=format: --no-notes ${{ github.event.before }}..${{ github.event.after }} -- package.json | cat) - echo "diff:" - echo "$diff" - echo "" + # get the next version as the version currently set in the root package.json + NEXT=$(jq -r '.version' package.json) - # grep for the version line - # next version will be the line added - next=$(echo "$diff" | grep -e "\+\s*\"version\"") - # previous version will be the line removed - prev=$(echo "$diff" | grep -e "-\s*\"version\"") - echo "version_changes:" - echo "$version_changes" - echo "" + # checkout the repo back to before this pr + git checkout ${{ github.event.before }} - # if the version line has changed then we know there's been a version change. Not necessarily bumped up, though! - # the next version will be whatever is currently in the package.json file - # subsequent steps can choose whether the version has been bumped or not. All we know at this stage is the version has been changed, i.e. new_version != old_version, but we don't know whether new_version > old_version or new_version < old_version - if [[ -n "$version_changes" ]]; then - echo "version has changed" - else - echo "version has not changed" - exit 1 - fi - - NEXT_VERSION=$(cat package.json | jq -r '.version' || echo "0.0.0") - # split into major, minor, patch - NEXT_MAJOR=$(echo $NEXT_VERSION | cut -d. -f1) - NEXT_MINOR=$(echo $NEXT_VERSION | cut -d. -f2) - NEXT_PATCH=$(echo $NEXT_VERSION | cut -d. -f3) - echo "next_version=$NEXT_VERSION" - echo "next_major=$MAJOR" - echo "next_minor=$MINOR" - echo "next_patch=$PATCH" - - # export the next version numbers - echo "version=$VERSION" >> $GITHUB_OUTPUT - echo "major=$MAJOR" >> $GITHUB_OUTPUT - echo "minor=$MINOR" >> $GITHUB_OUTPUT - echo "patch=$PATCH" >> $GITHUB_OUTPUT + # get the previous version as the version currently set in the root package.json in the before state + PREV=$(jq -r '.version' package.json) - - name: Check version has been bumped - run: | - set -eu - # get the previous version - # break into major, minor, patch - - # get the current version - # break into major, minor, patch + # switch back to the current state + git switch - - # check if the current version is greater than the previous version + # 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 From 50df1c1fe1034f6ba33f836f761c00ee5ba7380e Mon Sep 17 00:00:00 2001 From: George Oastler Date: Tue, 2 Jul 2024 12:24:01 +0100 Subject: [PATCH 39/72] auto merge all prs --- .github/workflows/auto_merge.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/auto_merge.yml b/.github/workflows/auto_merge.yml index 7ba211fa75..c4771ead56 100644 --- a/.github/workflows/auto_merge.yml +++ b/.github/workflows/auto_merge.yml @@ -4,7 +4,6 @@ name: auto_merge on: pull_request: - branches: [main, dev, release/*] types: - opened - reopened From 424a5ac18fbccc9441d4cf27cca4ff42d6205f86 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Tue, 2 Jul 2024 12:24:10 +0100 Subject: [PATCH 40/72] check consistent workflow names on all prs --- .github/workflows/consistent_workflow_names.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/consistent_workflow_names.yml b/.github/workflows/consistent_workflow_names.yml index f67feb12cb..862e85736d 100644 --- a/.github/workflows/consistent_workflow_names.yml +++ b/.github/workflows/consistent_workflow_names.yml @@ -4,7 +4,6 @@ name: consistent_workflow_names on: pull_request: - branches: [main, dev, release/*] # only when workflow file is changed paths: ['.github/workflows/**'] From 93412cf816509f1086a7b7b086b683ba9076af44 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Tue, 2 Jul 2024 15:01:07 +0100 Subject: [PATCH 41/72] branch system docs --- .github/branches.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/branches.md diff --git a/.github/branches.md b/.github/branches.md new file mode 100644 index 0000000000..56475575f6 --- /dev/null +++ b/.github/branches.md @@ -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 From adf4874af8ad285e8ab4028ac31295dc1097ac1a Mon Sep 17 00:00:00 2001 From: George Oastler Date: Tue, 2 Jul 2024 15:01:36 +0100 Subject: [PATCH 42/72] check contract version on prs to main,dev,release/* --- .github/workflows/contract_version.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/contract_version.yml b/.github/workflows/contract_version.yml index 5896529591..efa34d128d 100644 --- a/.github/workflows/contract_version.yml +++ b/.github/workflows/contract_version.yml @@ -4,7 +4,7 @@ name: contract_version on: pull_request: - branches: [main] + branches: [main, dev, release/*] paths: - '**/package.json' - '**/Cargo.toml' From f42b3b7706d974605fe5a2fe5672b2cdcd862e82 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Tue, 2 Jul 2024 17:18:16 +0100 Subject: [PATCH 43/72] add workflow_dispatch to all relevant workflows --- .github/workflows/consistent_workflow_names.yml | 1 + .github/workflows/release_version.yml | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/consistent_workflow_names.yml b/.github/workflows/consistent_workflow_names.yml index 862e85736d..63875d2d55 100644 --- a/.github/workflows/consistent_workflow_names.yml +++ b/.github/workflows/consistent_workflow_names.yml @@ -6,6 +6,7 @@ on: pull_request: # only when workflow file is changed paths: ['.github/workflows/**'] + workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} diff --git a/.github/workflows/release_version.yml b/.github/workflows/release_version.yml index 77a7364b8d..df40176180 100644 --- a/.github/workflows/release_version.yml +++ b/.github/workflows/release_version.yml @@ -4,7 +4,8 @@ name: release_version on: pull_request: - branches: [release/*] + branches: [main] + workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} From c78759439a06de9ef82efe84d8f52561d0718b78 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Tue, 2 Jul 2024 17:18:28 +0100 Subject: [PATCH 44/72] make auto merge only run on non-draft prs --- .github/workflows/auto_merge.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/auto_merge.yml b/.github/workflows/auto_merge.yml index c4771ead56..d3db59467d 100644 --- a/.github/workflows/auto_merge.yml +++ b/.github/workflows/auto_merge.yml @@ -54,9 +54,13 @@ 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 + if: github.event.pull_request.draft == false + run: npm i -g npm@$(cat package.json | jq -r .engines.npm) - name: Enable auto-merge on PR + if: github.event.pull_request.draft == false env: GITHUB_TOKEN: ${{ secrets.PROSOPONATOR_PAT }} run: | From 6506ceeda4c7cb88ef76f7bb4f548ceae5654fe5 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Tue, 2 Jul 2024 17:18:45 +0100 Subject: [PATCH 45/72] check versions on all branches --- .github/workflows/lockstep_version.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lockstep_version.yml b/.github/workflows/lockstep_version.yml index e5493eeb24..77b7666fe0 100644 --- a/.github/workflows/lockstep_version.yml +++ b/.github/workflows/lockstep_version.yml @@ -6,7 +6,7 @@ name: lockstep_version on: pull_request: - branches: [main] + branches: [main, dev, release/*] paths: - '**/package.json' - '**/Cargo.toml' From f3decd3f04ab779b999057cf2d9c25171702329e Mon Sep 17 00:00:00 2001 From: George Oastler Date: Tue, 2 Jul 2024 17:19:49 +0100 Subject: [PATCH 46/72] make release run on push to main --- .github/workflows/release.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8bff4ba7a7..4fe816aabf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,8 +4,7 @@ name: release on: push: - # only on the main branch - branches: [ release/* ] + branches: [ main ] jobs: publish: From 99ac204e072bd724c6635addaeaf49cd11068d7b Mon Sep 17 00:00:00 2001 From: George Oastler Date: Tue, 2 Jul 2024 17:24:48 +0100 Subject: [PATCH 47/72] tag pushes to main --- .github/workflows/release.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4fe816aabf..f6695e064a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -184,6 +184,12 @@ jobs: # Start the bundle demo & run the cypress tests against the new bundle # npx concurrently "npm run start:bundle" "npm run -w @prosopo/cypress-shared cypress:run:client-bundle-example:js_server" --success "first" --kill-others + - name: Tag + run: | + echo "Tagging the release..." + git tag -a "v${{ steps.next_version.outputs.version }}" -m "v${{ steps.next_version.outputs.version }}" + git push origin "v${{ steps.next_version.outputs.version }}" + - name: Github release continue-on-error: true id: github_release From 11fa7f2c352c0ea51c76cd473cc14d3f122263f9 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Tue, 2 Jul 2024 17:27:07 +0100 Subject: [PATCH 48/72] rename version check workflow --- .../workflows/{release_version.yml => check_version_bump.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{release_version.yml => check_version_bump.yml} (99%) diff --git a/.github/workflows/release_version.yml b/.github/workflows/check_version_bump.yml similarity index 99% rename from .github/workflows/release_version.yml rename to .github/workflows/check_version_bump.yml index df40176180..2e7eb60f9e 100644 --- a/.github/workflows/release_version.yml +++ b/.github/workflows/check_version_bump.yml @@ -1,6 +1,6 @@ # Check the version has been bumped before releasing -name: release_version +name: check_version_bump on: pull_request: From 0f8d3d0e714615bd175382738e8b255192ce08c2 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Tue, 2 Jul 2024 17:28:19 +0100 Subject: [PATCH 49/72] remove fetch all history and branches from clone --- .github/workflows/release.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f6695e064a..0b6ec1e23c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -54,9 +54,6 @@ jobs: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin 2> /dev/null - uses: actions/checkout@v3 - with: - # fetch all history + branches - fetch-depth: 0 - name: Next version id: next_version From fcd9ee2a601b41079af472e63db959d876ba4235 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Tue, 2 Jul 2024 17:52:16 +0100 Subject: [PATCH 50/72] fix docker js server version issue --- .github/workflows/release.yml | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0b6ec1e23c..d380635561 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -123,23 +123,13 @@ jobs: - name: Build docker js_server run: | + # technically, if the release is for a version which is less than a published version, the following code will have bundles from versions ahead of this one. However, this isn't really a problem, as we just want the latest bundle to be available alongside old ones, not so bothered about newer ones. + # Set the JS location in the container JS_FOLDER="/usr/share/nginx/html/js" # Get the most recent version of the js_server image - docker pull prosopo/js_server:${{ steps.next_version.outputs.version }} - - # get the previous version number from latest release on docker - VERSION=$(cd dev/gh-actions && npx tsx src/previousDockerTag.ts prosopo js_server ${{ steps.next_version.outputs.version }}) - - if [[ -z "$VERSION" ]]; then - echo "Failed to get previous version" - exit 1 - fi - - MAJOR=$(echo $VERSION | cut -d. -f1) - MINOR=$(echo $VERSION | cut -d. -f2) - PATCH=$(echo $VERSION | cut -d. -f3) + docker pull prosopo/js_server:latest # Create a temporary container from the latest image echo "Building Docker image..." From d78a1dd712bb7d5c0a2a9f776455ad243e244584 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Tue, 2 Jul 2024 18:00:23 +0100 Subject: [PATCH 51/72] fix bump workflow to bump all package.json files and Cargo.tomls --- .github/workflows/bump_version.yml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/bump_version.yml b/.github/workflows/bump_version.yml index b84670234c..2e790ad813 100644 --- a/.github/workflows/bump_version.yml +++ b/.github/workflows/bump_version.yml @@ -99,11 +99,19 @@ jobs: GITHUB_TOKEN: ${{ secrets.PROSOPONATOR_PAT }} run: | # 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 }} + + set -eu + # 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 }}\"' > %" <<< "$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 From dda17e0c98e8c0805d4de0a57d25ba255c8a5121 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Tue, 2 Jul 2024 18:12:05 +0100 Subject: [PATCH 52/72] fix package.json version writing in bump workflow --- .github/workflows/bump_version.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bump_version.yml b/.github/workflows/bump_version.yml index 2e790ad813..54f7fd9296 100644 --- a/.github/workflows/bump_version.yml +++ b/.github/workflows/bump_version.yml @@ -105,7 +105,7 @@ jobs: # 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 }}\"' > %" <<< "$pkgJsons" + 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/*') From ddac1237be7644a32a0ad483f18e3d51996fa093 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Wed, 3 Jul 2024 09:25:15 +0100 Subject: [PATCH 53/72] rename step --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d380635561..e66f531691 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,7 +7,7 @@ on: branches: [ main ] jobs: - publish: + release: runs-on: ubuntu-latest steps: - name: Print contexts From 8f07ff22aded23ccaf59120ca0a24ef633374174 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Wed, 3 Jul 2024 16:04:09 +0100 Subject: [PATCH 54/72] make auto merge cancellable --- .github/workflows/auto_merge.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/auto_merge.yml b/.github/workflows/auto_merge.yml index d3db59467d..556c620412 100644 --- a/.github/workflows/auto_merge.yml +++ b/.github/workflows/auto_merge.yml @@ -8,6 +8,10 @@ on: - opened - reopened +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: auto_merge: runs-on: ubuntu-latest From abced5d275bd44b486d99b59c483470b6e2a3ccd Mon Sep 17 00:00:00 2001 From: George Oastler Date: Wed, 3 Jul 2024 16:04:38 +0100 Subject: [PATCH 55/72] make deploy ahve a single notification of pass/fail --- .github/workflows/{release.yml => deploy.yml} | 101 +++--------------- 1 file changed, 13 insertions(+), 88 deletions(-) rename .github/workflows/{release.yml => deploy.yml} (63%) diff --git a/.github/workflows/release.yml b/.github/workflows/deploy.yml similarity index 63% rename from .github/workflows/release.yml rename to .github/workflows/deploy.yml index 2c50c26e99..7378977b0a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/deploy.yml @@ -1,13 +1,13 @@ -# Publish + deploy packages after a release +# Publish / release / deploy packages after a release -name: release +name: deploy on: push: branches: [ main ] jobs: - release: + deploy: runs-on: ubuntu-latest steps: - name: Print contexts @@ -167,14 +167,7 @@ jobs: # Start the bundle demo & run the cypress tests against the new bundle # npx concurrently "npm run start:bundle" "npm run -w @prosopo/cypress-shared cypress:run:client-bundle-example:js_server" --success "first" --kill-others - - name: Tag - run: | - echo "Tagging the release..." - git tag -a "v${{ steps.next_version.outputs.version }}" -m "v${{ steps.next_version.outputs.version }}" - git push origin "v${{ steps.next_version.outputs.version }}" - - name: Github release - continue-on-error: true id: github_release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -182,22 +175,7 @@ jobs: # do a gh release with the contract sources + bundle gh release create --generate-notes "v${{ steps.next_version.outputs.version }}" "./protocol/target/ink/captcha/captcha.contract" "./protocol/target/ink/proxy/proxy.contract" "./protocol/target/ink/common/common.contract" "./packages/procaptcha-bundle/dist/bundle/procaptcha.bundle.js" - - name: Github release notification - if: always() - run: | - if [[ "${{ steps.github_release.outcome }}" == 'success' ]]; then - echo "Github release successful." - curl -X POST -H 'Content-type: application/json' --data "{\"text\":\":check-passed: Github release has been published.\"}" ${{ secrets.SLACKBOT_DEVOPS }} - elif [[ "${{ steps.github_release.outcome }}" == 'failure' ]]; then - echo "Github release failed." - curl -X POST -H 'Content-type: application/json' --data "{\"text\":\":check-failed: Github release <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|v${{ steps.next_version.outputs.version }}> failed.\"}" ${{ secrets.SLACKBOT_DEVOPS }} - else - echo "Github release skipped / cancelled." - fi - - name: Npm release - continue-on-error: true - id: npm_release run: | if [[ "${{ vars.HOST_GITHUB_ACTIONS }}" == true ]]; then echo "Running on GitHub Actions" @@ -211,21 +189,7 @@ jobs: echo "Running locally via act, skipping npm publish." fi - - name: Npm release notification - if: always() - run: | - if [[ "${{ steps.npm_release.outcome }}" == 'success' ]]; then - echo "Npm release successful." - curl -X POST -H 'Content-type: application/json' --data "{\"text\":\":check-passed: Npm release has been published.\"}" ${{ secrets.SLACKBOT_DEVOPS }} - elif [[ "${{ steps.npm_release.outcome }}" == 'failure' ]]; then - echo "Npm release failed." - curl -X POST -H 'Content-type: application/json' --data "{\"text\":\":check-failed: Npm release <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|v${{ steps.next_version.outputs.version }}> failed.\"}" ${{ secrets.SLACKBOT_DEVOPS }} - else - echo "Npm release skipped / cancelled." - fi - - name: Docker js_server release - continue-on-error: true id: docker_js_server_release run: | # Push the new image to Docker Hub @@ -236,23 +200,7 @@ jobs: docker tag prosopo/js_server:${{ steps.next_version.outputs.version }} prosopo/js_server:latest docker push prosopo/js_server:latest - - name: Docker js_server release notification - if: always() - run: | - if [[ "${{ steps.docker_js_server_release.outcome }}" == 'success' ]]; then - echo "Docker js_server release successful." - curl -X POST -H 'Content-type: application/json' --data "{\"text\":\":check-passed: Docker js_server release has been published.\"}" ${{ secrets.SLACKBOT_DEVOPS }} - elif [[ "${{ steps.docker_js_server_release.outcome }}" == 'failure' ]]; then - echo "Docker js_server release failed." - curl -X POST -H 'Content-type: application/json' --data "{\"text\":\":check-failed: Docker js_server release <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|v${{ steps.next_version.outputs.version }}> failed.\"}" ${{ secrets.SLACKBOT_DEVOPS }} - else - echo "Docker js_server release skipped / cancelled." - fi - - name: Redeploy flux docker js_server - id: flux_docker_js_server_redeploy - continue-on-error: true - if: always() env: PROSOPO_ZELCORE_PRIVATE_KEY: ${{ secrets.PROSOPO_ZELCORE_PRIVATE_KEY }} PROSOPO_ZELCORE_PUBLIC_KEY: ${{ secrets.PROSOPO_ZELCORE_PUBLIC_KEY }} @@ -266,26 +214,6 @@ jobs: echo "Skipping flux redeploy." fi - - name: - if: always() - env: - PROSOPO_ZELCORE_PRIVATE_KEY: ${{ secrets.PROSOPO_ZELCORE_PRIVATE_KEY }} - PROSOPO_ZELCORE_PUBLIC_KEY: ${{ secrets.PROSOPO_ZELCORE_PUBLIC_KEY }} - run: | - if [[ "${{ steps.docker_js_server_release.outcome }}" == 'success' ]]; then - if [[ "${{ steps.flux_docker_js_server_redeploy.outcome }}" == 'success' ]]; then - echo "Redeployed flux docker js_server." - curl -X POST -H 'Content-type: application/json' --data "{\"text\":\":check-passed: Flux docker js_server redeploy <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|v${{ steps.next_version.outputs.version }}> has been requested.\"}" ${{ secrets.SLACKBOT_DEVOPS }} - elif [[ "${{ steps.flux_docker_js_server_redeploy.outcome }}" == 'failure' ]]; then - echo "Redeploying flux docker js_server failed." - curl -X POST -H 'Content-type: application/json' --data "{\"text\":\":check-failed: Flux docker js_server redeploy <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|v${{ steps.next_version.outputs.version }}> failed.\"}" ${{ secrets.SLACKBOT_DEVOPS }} - else - echo "Redeploying flux docker js_server skipped / cancelled." - fi - else - echo "Skipping flux redeploy notification." - fi - # Add support for more platforms with QEMU (optional) # https://github.com/docker/setup-qemu-action - name: Set up QEMU @@ -312,8 +240,6 @@ jobs: cd ../.. - name: Build and push the Provider Container - id: docker_provider_release - continue-on-error: true uses: docker/build-push-action@v5 with: context: ${{github.workspace}} @@ -322,15 +248,14 @@ jobs: push: true tags: prosopo/provider:${{ steps.next_version.outputs.version }},prosopo/provider:latest - - name: Docker provider release notification - if: always() + - name: Deploy fail notification + if: failure() run: | - if [[ "${{ steps.docker_provider_release.outcome }}" == 'success' ]]; then - echo "Docker provider release successful." - curl -X POST -H 'Content-type: application/json' --data "{\"text\":\":check-passed: Docker provider release has been published.\"}" ${{ secrets.SLACKBOT_DEVOPS }} - elif [[ "${{ steps.docker_provider_release.outcome }}" == 'failure' ]]; then - echo "Docker provider release failed." - curl -X POST -H 'Content-type: application/json' --data "{\"text\":\":check-failed: Docker provider release <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|v${{ steps.next_version.outputs.version }}> failed.\"}" ${{ secrets.SLACKBOT_DEVOPS }} - else - echo "Docker provider release skipped / cancelled." - fi + echo "Deploy failed" + curl -X POST -H 'Content-type: application/json' --data "{\"text\":\":check-failed: Deploy <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|v${{ steps.next_version.outputs.version }}> failed.\"}" ${{ secrets.SLACKBOT_DEVOPS }} + + - name: Deploy success notification + if: success() + run: | + echo "Deploy succeeded" + curl -X POST -H 'Content-type: application/json' --data "{\"text\":\":check-passed: Deploy <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|v${{ steps.next_version.outputs.version }}> succeeded.\"}" ${{ secrets.SLACKBOT_DEVOPS }} From d1e0f12546759e7816024489aa36296d82b85696 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Wed, 3 Jul 2024 16:04:45 +0100 Subject: [PATCH 56/72] debug info --- .github/workflows/check_version_bump.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/check_version_bump.yml b/.github/workflows/check_version_bump.yml index 2e7eb60f9e..79274ec35c 100644 --- a/.github/workflows/check_version_bump.yml +++ b/.github/workflows/check_version_bump.yml @@ -62,12 +62,14 @@ jobs: # 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 - From e7f10684b1de50f0c53388fb32d4d359b1d7f541 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Wed, 3 Jul 2024 16:04:53 +0100 Subject: [PATCH 57/72] fix cache workflow name --- .github/workflows/cache.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/cache.yml b/.github/workflows/cache.yml index ee588b0bca..4aa6af71b5 100644 --- a/.github/workflows/cache.yml +++ b/.github/workflows/cache.yml @@ -1,9 +1,7 @@ # Build a cache of build artifacts after PRs to speed up subsequent builds -name: post_pr +name: cache -# on push to main, or manually triggered -# we do this because any branch can use caches built on dev, whereas caches built on other branches are only available to that branch and its children on: push: branches: [main, dev] From 72e5911f72656297d0709528abd495f2ac58947d Mon Sep 17 00:00:00 2001 From: George Oastler Date: Wed, 3 Jul 2024 16:05:07 +0100 Subject: [PATCH 58/72] don't use cache in bump version workflow, not needed --- .github/workflows/bump_version.yml | 35 ------------------------------ 1 file changed, 35 deletions(-) diff --git a/.github/workflows/bump_version.yml b/.github/workflows/bump_version.yml index 54f7fd9296..e482efff89 100644 --- a/.github/workflows/bump_version.yml +++ b/.github/workflows/bump_version.yml @@ -59,41 +59,6 @@ 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-${{ github.event.pull_request.head.ref || github.ref }}-${{ 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 }} From 2eb1d6a4752994dfcb11f46bdcfcd2653c8c1059 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Wed, 3 Jul 2024 16:05:29 +0100 Subject: [PATCH 59/72] move buildx to top of workflow --- .github/workflows/deploy.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7378977b0a..74c1a052c4 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -48,6 +48,14 @@ jobs: echo "inputs:" "$INPUTS_CONTEXT" echo "******************************" + # Add support for more platforms with QEMU (optional) + # https://github.com/docker/setup-qemu-action + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Dockerhub login run: | echo "Logging into Docker Hub." @@ -214,13 +222,6 @@ jobs: echo "Skipping flux redeploy." fi - # Add support for more platforms with QEMU (optional) - # https://github.com/docker/setup-qemu-action - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - name: Build the production CLI package run: | From 490323ecc7c5c653b1150408401250812eea77b2 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Wed, 3 Jul 2024 16:06:53 +0100 Subject: [PATCH 60/72] move the cli building to before publishing images in deploy workflow --- .github/workflows/deploy.yml | 37 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 74c1a052c4..96a15e71ab 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -55,7 +55,7 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - + - name: Dockerhub login run: | echo "Logging into Docker Hub." @@ -175,6 +175,23 @@ jobs: # Start the bundle demo & run the cypress tests against the new bundle # npx concurrently "npm run start:bundle" "npm run -w @prosopo/cypress-shared cypress:run:client-bundle-example:js_server" --success "first" --kill-others + - name: Build the production CLI package + run: | + echo "Building the production CLI package..." + # Copy the rococo env file to production env file + echo "Copying the rococo env to production env file in cli package" + cp ./dev/scripts/env.production ./packages/cli/.env.production + + # Navigate to the provider CLI directory and build + echo "Navigating to 'packages/cli' and bundling..." + cd packages/cli + NODE_ENV=production npm run build + NODE_ENV=production npm run bundle:prod + + # Navigate back to the project root + echo "Navigating back to project root..." + cd ../.. + - name: Github release id: github_release env: @@ -222,24 +239,6 @@ jobs: echo "Skipping flux redeploy." fi - - - name: Build the production CLI package - run: | - echo "Building the production CLI package..." - # Copy the rococo env file to production env file - echo "Copying the rococo env to production env file in cli package" - cp ./dev/scripts/env.production ./packages/cli/.env.production - - # Navigate to the provider CLI directory and build - echo "Navigating to 'packages/cli' and bundling..." - cd packages/cli - NODE_ENV=production npm run build - NODE_ENV=production npm run bundle:prod - - # Navigate back to the project root - echo "Navigating back to project root..." - cd ../.. - - name: Build and push the Provider Container uses: docker/build-push-action@v5 with: From eec7a059888954c376ffeeade3366aace4c2b9f1 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Wed, 3 Jul 2024 16:16:46 +0100 Subject: [PATCH 61/72] tag warning --- .github/workflows/deploy.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 96a15e71ab..0001d195a5 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -191,7 +191,8 @@ jobs: # Navigate back to the project root echo "Navigating back to project root..." cd ../.. - + + # this will error if there's already a release for this version. This is by design, if you need to fix a release (e.g. because a deploy failed) then bump the version and try again - name: Github release id: github_release env: From 9c29b5307182eb4dead73f72f4a68b6312b80bd1 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Wed, 3 Jul 2024 16:31:06 +0100 Subject: [PATCH 62/72] remove filters for tests, test more often --- .github/workflows/cypress.yml | 7 ------- .github/workflows/provider_image.yml | 6 ------ .github/workflows/tests.yml | 7 ------- 3 files changed, 20 deletions(-) diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 30455ceaae..78aa0d1e4b 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -5,13 +5,6 @@ name: cypress on: pull_request: branches: [main, dev, release/*] - paths: - - 'docker/**' - - 'packages/**' - - 'demos/**' - - 'dev/**' - - 'contracts/**' - - '.github/workflows/cypress.yml' workflow_dispatch: concurrency: diff --git a/.github/workflows/provider_image.yml b/.github/workflows/provider_image.yml index 2be03cf88b..1acfe674ce 100644 --- a/.github/workflows/provider_image.yml +++ b/.github/workflows/provider_image.yml @@ -5,12 +5,6 @@ name: provider_image on: pull_request: branches: [main, dev, release/*] - paths: - - 'docker/**' - - 'dev/**' - - 'packages/**' - - 'contracts/**' - - '.github/workflows/provider_image.yml' workflow_dispatch: concurrency: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8489333890..8634e9c09f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -5,13 +5,6 @@ name: tests on: pull_request: branches: [main, dev, release/*] - paths: - - 'docker/**' - - 'packages/**' - - 'demos/**' - - 'dev/**' - - 'contracts/**' - - '.github/workflows/tests.yml' workflow_dispatch: concurrency: From 1d5b4f5d9614884186ed319a56fbee7b7c29062d Mon Sep 17 00:00:00 2001 From: George Oastler Date: Wed, 3 Jul 2024 16:34:49 +0100 Subject: [PATCH 63/72] add workflow dispatch to deploy workflow --- .github/workflows/deploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 0001d195a5..af14ca2b6b 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -5,6 +5,7 @@ name: deploy on: push: branches: [ main ] + workflow_dispatch: jobs: deploy: From f3731bab03dd08c3acc136678367648ae15da4ad Mon Sep 17 00:00:00 2001 From: George Oastler Date: Wed, 3 Jul 2024 17:27:49 +0100 Subject: [PATCH 64/72] add bash error catching --- .github/workflows/bump_version.yml | 3 ++- .github/workflows/cache.yml | 2 ++ .github/workflows/check_version_bump.yml | 2 ++ .github/workflows/consistent_workflow_names.yml | 2 ++ .github/workflows/contract_version.yml | 3 ++- .github/workflows/cypress.yml | 2 ++ .github/workflows/deploy.yml | 8 ++++++++ .github/workflows/lint.yml | 2 ++ .github/workflows/lockstep_version.yml | 3 ++- .github/workflows/provider_image.yml | 4 ++++ .github/workflows/tests.yml | 4 ++++ 11 files changed, 32 insertions(+), 3 deletions(-) diff --git a/.github/workflows/bump_version.yml b/.github/workflows/bump_version.yml index e482efff89..3e123779f0 100644 --- a/.github/workflows/bump_version.yml +++ b/.github/workflows/bump_version.yml @@ -63,10 +63,11 @@ jobs: 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 release/${{ github.event.inputs.version }} - set -eu # 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 diff --git a/.github/workflows/cache.yml b/.github/workflows/cache.yml index 4aa6af71b5..84acb3d50b 100644 --- a/.github/workflows/cache.yml +++ b/.github/workflows/cache.yml @@ -109,6 +109,8 @@ jobs: - 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 echo "Fetching list of cache key" 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) diff --git a/.github/workflows/check_version_bump.yml b/.github/workflows/check_version_bump.yml index 79274ec35c..bf355934dc 100644 --- a/.github/workflows/check_version_bump.yml +++ b/.github/workflows/check_version_bump.yml @@ -59,6 +59,8 @@ jobs: # 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) diff --git a/.github/workflows/consistent_workflow_names.yml b/.github/workflows/consistent_workflow_names.yml index 63875d2d55..d2c818ad60 100644 --- a/.github/workflows/consistent_workflow_names.yml +++ b/.github/workflows/consistent_workflow_names.yml @@ -58,6 +58,8 @@ jobs: - name: Check workflow names run: | + set -euxo pipefail # stop on errors, print commands, fail on pipe fails + cd .github/workflows # Iterate through files in the current directory for file in *.yml *.yaml; do diff --git a/.github/workflows/contract_version.yml b/.github/workflows/contract_version.yml index efa34d128d..cc0720d538 100644 --- a/.github/workflows/contract_version.yml +++ b/.github/workflows/contract_version.yml @@ -66,7 +66,8 @@ jobs: - name: Check contract version matches provider version run: | - set -eu + set -euxo pipefail # stop on errors, print commands, fail on pipe fails + # get the version of the contract in js pkg for contract in contracts/*; do echo "checking version in $contract" diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 78aa0d1e4b..daf1c6c48d 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -92,6 +92,8 @@ jobs: - name: Setup env run: | + set -euxo pipefail # stop on errors, print commands, fail on pipe fails + cp demos/client-example-server/env.development demos/client-example-server/.env.test cp demos/client-example/env.development demos/client-example/.env.test cp dev/scripts/env.test .env.test diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index af14ca2b6b..3f200f1f11 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -68,6 +68,8 @@ jobs: id: next_version run: | + set -euxo pipefail # stop on errors, print commands, fail on pipe fails + VERSION=$(cat package.json | jq -r '.version') # if version not detected, error @@ -116,6 +118,8 @@ jobs: - name: Build JS bundle run: | + set -euxo pipefail # stop on errors, print commands, fail on pipe fails + # Copy the rococo env file to production env file echo "Copying the rococo env to production env file in procaptcha-bundle" cp ./dev/scripts/env.production ./packages/procaptcha-bundle/.env.production @@ -128,6 +132,8 @@ jobs: - name: Build docker js_server run: | + set -euxo pipefail # stop on errors, print commands, fail on pipe fails + # technically, if the release is for a version which is less than a published version, the following code will have bundles from versions ahead of this one. However, this isn't really a problem, as we just want the latest bundle to be available alongside old ones, not so bothered about newer ones. # Set the JS location in the container @@ -178,6 +184,8 @@ jobs: - name: Build the production CLI package run: | + set -euxo pipefail # stop on errors, print commands, fail on pipe fails + echo "Building the production CLI package..." # Copy the rococo env file to production env file echo "Copying the rococo env to production env file in cli package" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a2e72a2c39..f72bb12b03 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -92,6 +92,8 @@ jobs: - name: lint run: | + set -euxo pipefail # stop on errors, print commands, fail on pipe fails + # get the files which have changed in the PR files=$(curl -L -s -H "Authorization: Bearer ${{ github.token }}" -H "Accept: application/vnd.github.v3+json" "${{ github.event.pull_request.url }}/files" | jq -r '.[] | .filename') diff --git a/.github/workflows/lockstep_version.yml b/.github/workflows/lockstep_version.yml index 77b7666fe0..c3b78a1533 100644 --- a/.github/workflows/lockstep_version.yml +++ b/.github/workflows/lockstep_version.yml @@ -68,7 +68,8 @@ jobs: - name: Check package versions are all moving in lockstep run: | - set -eu + 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 version from package.json files diff --git a/.github/workflows/provider_image.yml b/.github/workflows/provider_image.yml index 1acfe674ce..78bd66bc31 100644 --- a/.github/workflows/provider_image.yml +++ b/.github/workflows/provider_image.yml @@ -95,6 +95,8 @@ jobs: # build the cli production bundle - name: Build cli production bundle run: | + set -euxo pipefail # stop on errors, print commands, fail on pipe fails + cp ./dev/scripts/env.production ./packages/cli/.env.production cp ./dev/scripts/env.production ./.env.production NODE_ENV=production npm run -w @prosopo/cli bundle:prod @@ -148,6 +150,8 @@ jobs: # Check that the version command works when running the bundle in the provider image - name: Check provider bundle runs run: | + set -euxo pipefail # stop on errors, print commands, fail on pipe fails + CONTAINER=$(docker run -d -v "./.env.production:/usr/src/app/.env.production" prosopo/provider:dev /bin/sh -c 'NODE_ENV=production npx provider version') sleep 20s docker logs $CONTAINER >& provider.log diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8634e9c09f..77a431eb5f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -98,6 +98,8 @@ jobs: - name: Build JS bundle run: | + set -euxo pipefail # stop on errors, print commands, fail on pipe fails + # Copy the rococo env file to production env file echo "Copying the rococo env to production env file in procaptcha-bundle" cp ./dev/scripts/env.production ./packages/procaptcha-bundle/.env.production @@ -110,6 +112,8 @@ jobs: - name: Setup env run: | + set -euxo pipefail # stop on errors, print commands, fail on pipe fails + cp demos/client-example-server/env.development demos/client-example-server/.env.test cp demos/client-example/env.development demos/client-example/.env.test cp dev/scripts/env.test .env.test From f80f15711ce12f6c5ddb23cdc039ee99817413d0 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Wed, 3 Jul 2024 17:40:52 +0100 Subject: [PATCH 65/72] Create consistent_engine_node.yml --- .github/workflows/consistent_engine_node.yml | 81 ++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 .github/workflows/consistent_engine_node.yml diff --git a/.github/workflows/consistent_engine_node.yml b/.github/workflows/consistent_engine_node.yml new file mode 100644 index 0000000000..e088a373b7 --- /dev/null +++ b/.github/workflows/consistent_engine_node.yml @@ -0,0 +1,81 @@ +# Check the node versions are consistent across packages + +name: consistent_engine_node + +on: + pull_request: + branches: [main, dev, release/*] + paths: + - '**/package.json' + - '.github/workflows/consistent_engine_node.yml' + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always + ENVIRONMENT: development + GH_TOKEN: ${{ github.token }} + +jobs: + check: + runs-on: ubuntu-latest + 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 + + - name: Check contract version matches provider version + run: | + 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" + exit 1 + fi From b93648f56db85d8f8ad227e50c9ce0126742b48c Mon Sep 17 00:00:00 2001 From: George Oastler Date: Wed, 3 Jul 2024 17:40:55 +0100 Subject: [PATCH 66/72] Create consistent_engine_npm.yml --- .github/workflows/consistent_engine_npm.yml | 81 +++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 .github/workflows/consistent_engine_npm.yml diff --git a/.github/workflows/consistent_engine_npm.yml b/.github/workflows/consistent_engine_npm.yml new file mode 100644 index 0000000000..60883178e2 --- /dev/null +++ b/.github/workflows/consistent_engine_npm.yml @@ -0,0 +1,81 @@ +# Check the npm versions are consistent across packages + +name: consistent_engine_npm + +on: + pull_request: + branches: [main, dev, release/*] + paths: + - '**/package.json' + - '.github/workflows/consistent_engine_npm.yml' + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always + ENVIRONMENT: development + GH_TOKEN: ${{ github.token }} + +jobs: + check: + runs-on: ubuntu-latest + 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 + + - name: Check contract version matches provider version + run: | + 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 npm version from the package.json files + versions=$(jq -r '.engines.npm' $pkgJsons) + + # ensure all npm versions are the same + if [ $(echo "$versions" | uniq | wc -l) -ne 1 ]; then + echo "Npm versions are not consistent across packages" + echo "$versions" + exit 1 + fi From bb2c59e8a58e2b22868c4a564d5ca4c7c700269f Mon Sep 17 00:00:00 2001 From: George Oastler Date: Wed, 3 Jul 2024 17:40:58 +0100 Subject: [PATCH 67/72] Create consistent_nvmrc.yml --- .github/workflows/consistent_nvmrc.yml | 90 ++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 .github/workflows/consistent_nvmrc.yml diff --git a/.github/workflows/consistent_nvmrc.yml b/.github/workflows/consistent_nvmrc.yml new file mode 100644 index 0000000000..020da812c1 --- /dev/null +++ b/.github/workflows/consistent_nvmrc.yml @@ -0,0 +1,90 @@ +# Check the npm versions are consistent across packages + +name: consistent_nvmrc + +on: + pull_request: + branches: [main, dev, release/*] + paths: + - '**/package.json' + - '**/.nvmrc' + - '.github/workflows/consistent_engine_node_and_nvmrc.yml' + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always + ENVIRONMENT: development + GH_TOKEN: ${{ github.token }} + +jobs: + check: + runs-on: ubuntu-latest + 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 + + - name: Check contract version matches provider version + run: | + set -euxo pipefail # stop on errors, print commands, fail on pipe fails + + # find all .nvmrc files except in node_modules and get the content + nvmrcs=$(find . -name '.nvmrc' -not -path '*/node_modules/*' -exec cat {} +) + + # check all .nvmrc files are the same content + if [ $(echo "$nvmrcs" | uniq | wc -l) -gt 1 ]; then + echo "ERROR: .nvmrc files are not consistent" + echo "$nvmrcs" + exit 1 + fi + + # check nvmrc version matches engine + engine=$(jq -r '.engines.node' package.json) + + if [ "$engine" != "$(cat .nvmrc)" ]; then + echo "ERROR: .nvmrc version does not match engine" + echo "engine: $engine" + echo ".nvmrc: $(cat .nvmrc)" + exit 1 + fi + From be8b86a86d1bb5f76c225a5c74f5f8dfd6e7bd72 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Wed, 3 Jul 2024 17:43:49 +0100 Subject: [PATCH 68/72] cache docs --- .github/workflows/cypress.yml | 1 + .github/workflows/lint.yml | 1 + .github/workflows/ls_cache.yml | 1 + .github/workflows/protocol_clippy.yml | 1 + .github/workflows/protocol_rustfmt.yml | 1 + .github/workflows/protocol_tests.yml | 1 + .github/workflows/provider_image.yml | 1 + .github/workflows/tests.yml | 1 + 8 files changed, 8 insertions(+) diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index daf1c6c48d..8bb38da9e7 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -68,6 +68,7 @@ jobs: - name: Restore cache uses: actions/cache/restore@v3 with: + # must restore all cache dirs, and they must exist ahead of this! path: | protocol/cargo-cache protocol/target diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f72bb12b03..14a73e4f15 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -69,6 +69,7 @@ jobs: - name: Restore cache uses: actions/cache/restore@v3 with: + # must restore all cache dirs, and they must exist ahead of this! path: | protocol/cargo-cache protocol/target diff --git a/.github/workflows/ls_cache.yml b/.github/workflows/ls_cache.yml index c3e63d5429..766a71bf38 100644 --- a/.github/workflows/ls_cache.yml +++ b/.github/workflows/ls_cache.yml @@ -65,6 +65,7 @@ jobs: - name: Restore cache uses: actions/cache/restore@v3 with: + # must restore all cache dirs, and they must exist ahead of this! path: | protocol/cargo-cache protocol/target diff --git a/.github/workflows/protocol_clippy.yml b/.github/workflows/protocol_clippy.yml index be9279d691..33d0dd6d42 100644 --- a/.github/workflows/protocol_clippy.yml +++ b/.github/workflows/protocol_clippy.yml @@ -71,6 +71,7 @@ jobs: - name: Restore cache uses: actions/cache/restore@v3 with: + # must restore all cache dirs, and they must exist ahead of this! path: | protocol/cargo-cache protocol/target diff --git a/.github/workflows/protocol_rustfmt.yml b/.github/workflows/protocol_rustfmt.yml index 2b4498324a..4352782960 100644 --- a/.github/workflows/protocol_rustfmt.yml +++ b/.github/workflows/protocol_rustfmt.yml @@ -71,6 +71,7 @@ jobs: - name: Restore cache uses: actions/cache/restore@v3 with: + # must restore all cache dirs, and they must exist ahead of this! path: | protocol/cargo-cache protocol/target diff --git a/.github/workflows/protocol_tests.yml b/.github/workflows/protocol_tests.yml index 3929d6684b..06252b78a9 100644 --- a/.github/workflows/protocol_tests.yml +++ b/.github/workflows/protocol_tests.yml @@ -71,6 +71,7 @@ jobs: - name: Restore cache uses: actions/cache/restore@v3 with: + # must restore all cache dirs, and they must exist ahead of this! path: | protocol/cargo-cache protocol/target diff --git a/.github/workflows/provider_image.yml b/.github/workflows/provider_image.yml index 78bd66bc31..d1dff11e6c 100644 --- a/.github/workflows/provider_image.yml +++ b/.github/workflows/provider_image.yml @@ -67,6 +67,7 @@ jobs: - name: Restore cache uses: actions/cache/restore@v3 with: + # must restore all cache dirs, and they must exist ahead of this! path: | protocol/cargo-cache protocol/target diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 77a431eb5f..2d56b6fe37 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -68,6 +68,7 @@ jobs: - name: Restore cache uses: actions/cache/restore@v3 with: + # must restore all cache dirs, and they must exist ahead of this! path: | protocol/cargo-cache protocol/target From 95483adcfa7474b9acfc7c2b67b66486f06fa0e9 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Wed, 3 Jul 2024 18:04:52 +0100 Subject: [PATCH 69/72] event workflows for main and dev --- .github/workflows/event_dev_push.yml | 69 +++++++++++++++++++++++++++ .github/workflows/event_main_push.yml | 69 +++++++++++++++++++++++++++ 2 files changed, 138 insertions(+) create mode 100644 .github/workflows/event_dev_push.yml create mode 100644 .github/workflows/event_main_push.yml diff --git a/.github/workflows/event_dev_push.yml b/.github/workflows/event_dev_push.yml new file mode 100644 index 0000000000..10689cef7b --- /dev/null +++ b/.github/workflows/event_dev_push.yml @@ -0,0 +1,69 @@ +# Send an event to other repos on push to main + +name: event_dev_push + +on: + push: + branches: [dev] + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always + ENVIRONMENT: development + GH_TOKEN: ${{ github.token }} + +jobs: + event: + runs-on: ubuntu-latest + 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 "******************************" + + - name: Send event + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + curl -X POST \ + -H "Authorization: token $GITHUB_TOKEN" \ + -H "Accept: application/vnd.github.everest-preview+json" \ + -d '{"event_type": "custom-event-type", "client_payload": {"from": "prosopo/captcha", "event": "push", "branch": "dev"}}' \ + https://api.github.com/repos/prosopo/captcha-private/dispatches diff --git a/.github/workflows/event_main_push.yml b/.github/workflows/event_main_push.yml new file mode 100644 index 0000000000..66da455958 --- /dev/null +++ b/.github/workflows/event_main_push.yml @@ -0,0 +1,69 @@ +# Send an event to other repos on push to main + +name: event_main_push + +on: + push: + branches: [main] + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always + ENVIRONMENT: development + GH_TOKEN: ${{ github.token }} + +jobs: + event: + runs-on: ubuntu-latest + 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 "******************************" + + - name: Send event + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + curl -X POST \ + -H "Authorization: token $GITHUB_TOKEN" \ + -H "Accept: application/vnd.github.everest-preview+json" \ + -d '{"event_type": "custom-event-type", "client_payload": {"from": "prosopo/captcha", "event": "push", "branch": "main"}}' \ + https://api.github.com/repos/prosopo/captcha-private/dispatches From 84d2d65b396ec13f9ea879756a149c6c8274dbfb Mon Sep 17 00:00:00 2001 From: George Oastler Date: Wed, 3 Jul 2024 18:07:30 +0100 Subject: [PATCH 70/72] change event setup --- .github/workflows/event_dev_push.yml | 2 +- .github/workflows/event_main_push.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/event_dev_push.yml b/.github/workflows/event_dev_push.yml index 10689cef7b..1e8b615ff6 100644 --- a/.github/workflows/event_dev_push.yml +++ b/.github/workflows/event_dev_push.yml @@ -65,5 +65,5 @@ jobs: curl -X POST \ -H "Authorization: token $GITHUB_TOKEN" \ -H "Accept: application/vnd.github.everest-preview+json" \ - -d '{"event_type": "custom-event-type", "client_payload": {"from": "prosopo/captcha", "event": "push", "branch": "dev"}}' \ + -d '{"event_type": "captcha_dev_push"}' \ https://api.github.com/repos/prosopo/captcha-private/dispatches diff --git a/.github/workflows/event_main_push.yml b/.github/workflows/event_main_push.yml index 66da455958..de28beaa14 100644 --- a/.github/workflows/event_main_push.yml +++ b/.github/workflows/event_main_push.yml @@ -65,5 +65,5 @@ jobs: curl -X POST \ -H "Authorization: token $GITHUB_TOKEN" \ -H "Accept: application/vnd.github.everest-preview+json" \ - -d '{"event_type": "custom-event-type", "client_payload": {"from": "prosopo/captcha", "event": "push", "branch": "main"}}' \ + -d '{"event_type": "captcha_main_push"}' \ https://api.github.com/repos/prosopo/captcha-private/dispatches From d7f2d8465d442b070e34758b8a62cbfa0e6d50ce Mon Sep 17 00:00:00 2001 From: George Oastler Date: Wed, 3 Jul 2024 20:54:12 +0100 Subject: [PATCH 71/72] don't run unless non-draft pr --- .github/workflows/auto_merge.yml | 3 +-- .github/workflows/check_version_bump.yml | 1 + .github/workflows/consistent_engine_node.yml | 1 + .github/workflows/consistent_engine_npm.yml | 1 + .github/workflows/consistent_nvmrc.yml | 1 + .github/workflows/consistent_workflow_names.yml | 1 + .github/workflows/contract_version.yml | 1 + .github/workflows/cypress.yml | 1 + .github/workflows/lint.yml | 1 + .github/workflows/lockstep_version.yml | 1 + .github/workflows/protocol_clippy.yml | 1 + .github/workflows/protocol_rustfmt.yml | 1 + .github/workflows/protocol_tests.yml | 1 + .github/workflows/provider_image.yml | 1 + .github/workflows/tests.yml | 1 + 15 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/auto_merge.yml b/.github/workflows/auto_merge.yml index 556c620412..1c3d8e58ab 100644 --- a/.github/workflows/auto_merge.yml +++ b/.github/workflows/auto_merge.yml @@ -15,6 +15,7 @@ concurrency: jobs: auto_merge: runs-on: ubuntu-latest + if: github.event.pull_request.draft == false steps: - name: Print contexts env: @@ -60,11 +61,9 @@ jobs: node-version-file: '.nvmrc' - name: Install - if: github.event.pull_request.draft == false run: npm i -g npm@$(cat package.json | jq -r .engines.npm) - name: Enable auto-merge on PR - if: github.event.pull_request.draft == false env: GITHUB_TOKEN: ${{ secrets.PROSOPONATOR_PAT }} run: | diff --git a/.github/workflows/check_version_bump.yml b/.github/workflows/check_version_bump.yml index bf355934dc..a344e163b9 100644 --- a/.github/workflows/check_version_bump.yml +++ b/.github/workflows/check_version_bump.yml @@ -14,6 +14,7 @@ concurrency: jobs: check: runs-on: ubuntu-latest + if: github.event.pull_request.draft == false steps: - name: Print contexts env: diff --git a/.github/workflows/consistent_engine_node.yml b/.github/workflows/consistent_engine_node.yml index e088a373b7..a435040c99 100644 --- a/.github/workflows/consistent_engine_node.yml +++ b/.github/workflows/consistent_engine_node.yml @@ -22,6 +22,7 @@ env: jobs: check: runs-on: ubuntu-latest + if: github.event.pull_request.draft == false steps: - name: Print contexts env: diff --git a/.github/workflows/consistent_engine_npm.yml b/.github/workflows/consistent_engine_npm.yml index 60883178e2..89ba5986dd 100644 --- a/.github/workflows/consistent_engine_npm.yml +++ b/.github/workflows/consistent_engine_npm.yml @@ -22,6 +22,7 @@ env: jobs: check: runs-on: ubuntu-latest + if: github.event.pull_request.draft == false steps: - name: Print contexts env: diff --git a/.github/workflows/consistent_nvmrc.yml b/.github/workflows/consistent_nvmrc.yml index 020da812c1..b29390a677 100644 --- a/.github/workflows/consistent_nvmrc.yml +++ b/.github/workflows/consistent_nvmrc.yml @@ -23,6 +23,7 @@ env: jobs: check: runs-on: ubuntu-latest + if: github.event.pull_request.draft == false steps: - name: Print contexts env: diff --git a/.github/workflows/consistent_workflow_names.yml b/.github/workflows/consistent_workflow_names.yml index d2c818ad60..2a3fba342f 100644 --- a/.github/workflows/consistent_workflow_names.yml +++ b/.github/workflows/consistent_workflow_names.yml @@ -15,6 +15,7 @@ concurrency: jobs: check: runs-on: ubuntu-latest + if: github.event.pull_request.draft == false steps: - name: Print contexts env: diff --git a/.github/workflows/contract_version.yml b/.github/workflows/contract_version.yml index cc0720d538..c508a4ab14 100644 --- a/.github/workflows/contract_version.yml +++ b/.github/workflows/contract_version.yml @@ -23,6 +23,7 @@ env: jobs: check: runs-on: ubuntu-latest + if: github.event.pull_request.draft == false steps: - name: Print contexts env: diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 8bb38da9e7..b6936c4504 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -19,6 +19,7 @@ env: jobs: check: runs-on: ubuntu-latest + if: github.event.pull_request.draft == false steps: - name: Print contexts env: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 14a73e4f15..a70d12f218 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -20,6 +20,7 @@ jobs: check: name: check runs-on: ubuntu-latest + if: github.event.pull_request.draft == false steps: - name: Print contexts env: diff --git a/.github/workflows/lockstep_version.yml b/.github/workflows/lockstep_version.yml index c3b78a1533..913399f681 100644 --- a/.github/workflows/lockstep_version.yml +++ b/.github/workflows/lockstep_version.yml @@ -25,6 +25,7 @@ env: jobs: check: runs-on: ubuntu-latest + if: github.event.pull_request.draft == false steps: - name: Print contexts env: diff --git a/.github/workflows/protocol_clippy.yml b/.github/workflows/protocol_clippy.yml index 33d0dd6d42..4a9aeb7aad 100644 --- a/.github/workflows/protocol_clippy.yml +++ b/.github/workflows/protocol_clippy.yml @@ -22,6 +22,7 @@ env: jobs: check: runs-on: ubuntu-latest + if: github.event.pull_request.draft == false steps: - name: Print contexts env: diff --git a/.github/workflows/protocol_rustfmt.yml b/.github/workflows/protocol_rustfmt.yml index 4352782960..659465b331 100644 --- a/.github/workflows/protocol_rustfmt.yml +++ b/.github/workflows/protocol_rustfmt.yml @@ -22,6 +22,7 @@ env: jobs: check: runs-on: ubuntu-latest + if: github.event.pull_request.draft == false steps: - name: Print contexts env: diff --git a/.github/workflows/protocol_tests.yml b/.github/workflows/protocol_tests.yml index 06252b78a9..2ad541706c 100644 --- a/.github/workflows/protocol_tests.yml +++ b/.github/workflows/protocol_tests.yml @@ -22,6 +22,7 @@ env: jobs: check: runs-on: ubuntu-latest + if: github.event.pull_request.draft == false steps: - name: Print contexts env: diff --git a/.github/workflows/provider_image.yml b/.github/workflows/provider_image.yml index d1dff11e6c..bd50f455f2 100644 --- a/.github/workflows/provider_image.yml +++ b/.github/workflows/provider_image.yml @@ -18,6 +18,7 @@ env: jobs: check: runs-on: ubuntu-latest + if: github.event.pull_request.draft == false steps: - name: Print contexts env: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2d56b6fe37..08c922933d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -19,6 +19,7 @@ env: jobs: check: runs-on: ubuntu-latest + if: github.event.pull_request.draft == false steps: - name: Print contexts env: From 2bc4ad992cead15a44a14e7c66912f18326f2c80 Mon Sep 17 00:00:00 2001 From: George Oastler Date: Wed, 3 Jul 2024 20:56:08 +0100 Subject: [PATCH 72/72] combine protocol clippy and rustfmt into single lint workflow --- ...{protocol_clippy.yml => protocol_lint.yml} | 6 +- .github/workflows/protocol_rustfmt.yml | 95 ------------------- 2 files changed, 4 insertions(+), 97 deletions(-) rename .github/workflows/{protocol_clippy.yml => protocol_lint.yml} (96%) delete mode 100644 .github/workflows/protocol_rustfmt.yml diff --git a/.github/workflows/protocol_clippy.yml b/.github/workflows/protocol_lint.yml similarity index 96% rename from .github/workflows/protocol_clippy.yml rename to .github/workflows/protocol_lint.yml index 4a9aeb7aad..cb94b6a865 100644 --- a/.github/workflows/protocol_clippy.yml +++ b/.github/workflows/protocol_lint.yml @@ -1,6 +1,6 @@ -# This workflow will run clippy on the protocol workspace +# This workflow will run linting on the protocol workspace -name: protocol_clippy +name: protocol_lint on: pull_request: @@ -92,4 +92,6 @@ jobs: - run: npm ci + - run: npm -w @prosopo/protocol run rustfmt + - run: npm -w @prosopo/protocol run clippy diff --git a/.github/workflows/protocol_rustfmt.yml b/.github/workflows/protocol_rustfmt.yml deleted file mode 100644 index 659465b331..0000000000 --- a/.github/workflows/protocol_rustfmt.yml +++ /dev/null @@ -1,95 +0,0 @@ -# This workflow will run rustfmt on the protocol workspace - -name: protocol_rustfmt - -on: - pull_request: - branches: [main, dev, release/*] - paths: - - 'protocol/**' - - '.github/workflows/protocol_rustfmt.yml' - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -env: - CARGO_TERM_COLOR: always - ENVIRONMENT: development - GH_TOKEN: ${{ github.token }} - -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 - - - 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: - # must restore all cache dirs, and they must exist ahead of this! - 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-${{ github.event.pull_request.head.ref || github.ref }}-${{ runner.os }}-${{ runner.arch }}- - - - 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 -w @prosopo/protocol run rustfmt