Skip to content

Commit

Permalink
feat: enforce version bump on PRs to main
Browse files Browse the repository at this point in the history
  • Loading branch information
kylezs committed Dec 14, 2023
1 parent f28c005 commit d1a2b8a
Show file tree
Hide file tree
Showing 15 changed files with 134 additions and 16 deletions.
Empty file added .github/toml_version.ts
Empty file.
48 changes: 48 additions & 0 deletions .github/workflows/_05_force_version_bump.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

on:
workflow_call:

jobs:
force-version-bump:
runs-on: [digitalocean]
steps:
- name: Checkout backend
uses: actions/checkout@v2

- name: Configure NodeJS
uses: actions/setup-node@v3
with:
node-version: 18
cache: "pnpm"
registry-url: "https://npm.pkg.github.com"
scope: "@chainflip-io"
cache-dependency-path: "bouncer/pnpm-lock.yaml"
- name: Download latest release binaries
uses: dawidd6/action-download-artifact@v2
with:
workflow: release-perseverance.yml
name: chainflip-backend-bin-ubuntu-22.04
github_token: ${{ secrets.CF_BACKEND_GITHUB_TOKEN }}
path: latest-release-bins
- name: Permissions for latest binaries
run: |
chmod +x ./latest-release-bins/chainflip-*
- name: Version of the latest release
run: |
set -x
echo $(pwd)
RELEASE_VERSION=$(./latest-release-bins/chainflip-engine --version)
echo $RELEASE_VERSION
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV
- name: Install node dependencies
working-directory: bouncer
run: pnpm install

- name: Check the version of the branch is greater than the current release
working-directory: bouncer
run: |
set -x
echo ${{ env.RELEASE_VERSION }}
./commands/read_workspace_tomls.ts ${{ github.workspace }} "${{ env.RELEASE_VERSION }}"
3 changes: 3 additions & 0 deletions .github/workflows/ci-development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ jobs:
pre-check:
uses: ./.github/workflows/_01_pre_check.yml
secrets: inherit
force-version-bump:
uses: ./.github/workflows/_05_force_version_bump.yml
secrets: inherit
test:
uses: ./.github/workflows/_10_test.yml
secrets: inherit
Expand Down
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions api/bin/chainflip-broker-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
authors = ["Chainflip team <https://github.com/chainflip-io>"]
name = "chainflip-broker-api"
version = "1.1.0"
version = "1.1.2"
edition = "2021"

[package.metadata.deb]
Expand Down Expand Up @@ -35,4 +35,4 @@ tracing = "0.1.34"
tracing-subscriber = { version = "0.3.3", features = ["env-filter"] }

[build-dependencies]
substrate-build-script-utils = { git = "https://github.com/chainflip-io/substrate.git", tag = 'chainflip-monthly-2023-08+3' }
substrate-build-script-utils = { git = "https://github.com/chainflip-io/substrate.git", tag = 'chainflip-monthly-2023-08+3' }
2 changes: 1 addition & 1 deletion api/bin/chainflip-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ authors = ["Chainflip team <https://github.com/chainflip-io>"]
edition = '2021'
build = 'build.rs'
name = "chainflip-cli"
version = "1.1.0"
version = "1.1.2"

[dependencies]
anyhow = "1.0"
Expand Down
4 changes: 2 additions & 2 deletions api/bin/chainflip-lp-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
authors = ["Chainflip team <https://github.com/chainflip-io>"]
name = "chainflip-lp-api"
version = "1.1.0"
version = "1.1.2"
edition = "2021"

[package.metadata.deb]
Expand Down Expand Up @@ -41,4 +41,4 @@ chainflip-api = { path = "../../lib" }
cf-utilities = { package = "utilities", path = "../../../utilities" }

[build-dependencies]
substrate-build-script-utils = { git = "https://github.com/chainflip-io/substrate.git", tag = 'chainflip-monthly-2023-08+3' }
substrate-build-script-utils = { git = "https://github.com/chainflip-io/substrate.git", tag = 'chainflip-monthly-2023-08+3' }
1 change: 1 addition & 0 deletions bouncer/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tmp
3 changes: 2 additions & 1 deletion bouncer/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pnpm-lock.yaml
node_modules
node_modules
tmp
57 changes: 57 additions & 0 deletions bouncer/commands/read_workspace_tomls.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env -S pnpm tsx

import fs from 'fs';
import toml from '@iarna/toml';
import { compareSemVer } from '../shared/utils';

const projectRoot = process.argv[2];
const engineReleaseVersion = process.argv[3];

export function tomlVersion(cargoFilePath: string): Promise<string> {
return new Promise((resolve, reject) => {
fs.readFile(cargoFilePath, 'utf-8', (err, data) => {
if (err) {
reject(new Error('Error reading file: ' + err.message));
return;
}

try {
const cargoToml = toml.parse(data);
resolve(cargoToml.package.version);
} catch (error) {
reject(new Error('Error parsing TOML: ' + error.message));
}
});
});
}

const versionRegex = /\d+\.\d+\.\d+/;
const releaseVersion = engineReleaseVersion.match(versionRegex)[0];

// Ensure all the versions are the same
const engineTomlVersion = await tomlVersion(`${projectRoot}/engine/Cargo.toml`);
const runtimeTomlVersion = await tomlVersion(`${projectRoot}/state-chain/runtime/Cargo.toml`);
const nodeTomlVersion = await tomlVersion(`${projectRoot}/state-chain/node/Cargo.toml`);
const cliTomlVersion = await tomlVersion(`${projectRoot}/api/bin/chainflip-cli/Cargo.toml`);
const lpApiTomlVersion = await tomlVersion(`${projectRoot}/api/bin/chainflip-lp-api/Cargo.toml`);
const brokerTomlVersion = await tomlVersion(
`${projectRoot}/api/bin/chainflip-broker-api/Cargo.toml`,
);

if (
!(
engineTomlVersion === runtimeTomlVersion &&
runtimeTomlVersion === nodeTomlVersion &&
nodeTomlVersion === cliTomlVersion &&
cliTomlVersion === lpApiTomlVersion &&
lpApiTomlVersion === brokerTomlVersion
)
) {
throw Error('All versions should be the same');
} else if (compareSemVer(engineTomlVersion, releaseVersion) === 'greater') {
console.log(`Version is correct. Your branch has a version greater than the current release.`);
} else {
throw Error(
`Version is incorrect. The version of your branch (${engineTomlVersion}) should be greater than the current release (${releaseVersion}).)`,
);
}
1 change: 1 addition & 0 deletions bouncer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
},
"dependencies": {
"@chainflip-io/cli": "^0.1.5-rc.1",
"@iarna/toml": "^2.2.5",
"@polkadot/api": "10.7.2",
"@polkadot/keyring": "12.2.1",
"@polkadot/util": "12.2.1",
Expand Down
9 changes: 8 additions & 1 deletion bouncer/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ authors = ["Chainflip team <https://github.com/chainflip-io>"]
build = 'build.rs'
edition = '2021'
name = "chainflip-engine"
version = '1.1.0'
version = '1.1.2'

[package.metadata.deb]
depends = "$auto, systemd"
Expand Down
2 changes: 1 addition & 1 deletion state-chain/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license = '<TODO>'
name = 'chainflip-node'
publish = false
repository = 'https://github.com/chainflip-io/chainflip-backend'
version = '1.1.0'
version = '1.1.2'

[[bin]]
name = 'chainflip-node'
Expand Down
2 changes: 1 addition & 1 deletion state-chain/runtime/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = 'state-chain-runtime'
version = '1.1.0'
version = '1.1.2'
authors = ['Chainflip Team <https://github.com/chainflip-io>']
edition = '2021'
homepage = 'https://chainflip.io'
Expand Down

0 comments on commit d1a2b8a

Please sign in to comment.