Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

main #318

Merged
merged 104 commits into from
Jun 6, 2022
Merged

main #318

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
cf12e9e
Increase svgshot timeout
Zemnmez May 25, 2022
f14e1bb
Merge pull request #261 from Zemnmez/increase-svgshot-timeout
Zemnmez May 26, 2022
d1a379a
Remove dependency on docker
Zemnmez May 26, 2022
d0e31f8
Merge branch 'main' into no-docker
Zemnmez May 26, 2022
07f1643
Remove broken docker code
Zemnmez May 26, 2022
dab2f58
Bump stylelint from 14.8.4 to 14.8.5 (#264)
dependabot[bot] May 26, 2022
8105bec
Bump @testing-library/react from 12.1.2 to 13.2.0 (#260)
dependabot[bot] May 26, 2022
1a507c1
Bump electron-to-chromium from 1.4.137 to 1.4.139 (#265)
dependabot[bot] May 26, 2022
3d5d2f1
Merge branch 'main' into no-docker
Zemnmez May 26, 2022
d0e8ae6
Merge pull request #263 from Zemnmez/no-docker
Zemnmez May 26, 2022
e05f36a
Bump electron-to-chromium from 1.4.139 to 1.4.140 (#266)
dependabot[bot] May 27, 2022
294a5b8
Bump caniuse-lite from 1.0.30001342 to 1.0.30001343
dependabot[bot] May 27, 2022
ff26e24
Bump ws from 7.5.7 to 7.5.8 (#267)
dependabot[bot] May 27, 2022
171113f
Bump aws-sdk from 2.1142.0 to 2.1144.0 (#271)
dependabot[bot] May 27, 2022
7824f38
Bump follow-redirects from 1.15.0 to 1.15.1 (#268)
dependabot[bot] May 27, 2022
6f4313f
Remove all references to the vestigial typescript-transform-paths
Zemnmez May 27, 2022
b6289f9
Merge branch 'main' into no-typescript-transform-paths
Zemnmez May 27, 2022
d98f387
Merge pull request #273 from Zemnmez/no-typescript-transform-paths
Zemnmez May 27, 2022
e5faa39
Merge branch 'main' into dependabot/npm_and_yarn/caniuse-lite-1.0.300…
Zemnmez May 27, 2022
ea4b77c
Merge pull request #272 from Zemnmez/dependabot/npm_and_yarn/caniuse-…
Zemnmez May 27, 2022
0011efe
fix lint
Zemnmez May 27, 2022
19db598
Merge branch 'main' into fix-lint
Zemnmez May 27, 2022
a720a80
Merge pull request #275 from Zemnmez/fix-lint
Zemnmez May 27, 2022
c13724e
Bump @testing-library/react from 13.2.0 to 13.3.0 (#276)
dependabot[bot] May 30, 2022
5e6c372
Bump caniuse-lite from 1.0.30001343 to 1.0.30001344 (#278)
dependabot[bot] May 30, 2022
9297294
Bump electron-to-chromium from 1.4.140 to 1.4.141 (#280)
dependabot[bot] May 30, 2022
f9143ca
Bump aws-sdk from 2.1144.0 to 2.1145.0 (#283)
dependabot[bot] May 30, 2022
db946b9
Bump @types/node from 17.0.35 to 17.0.36 (#279)
dependabot[bot] May 30, 2022
f959478
Bump esbuild from 0.14.39 to 0.14.42 (#277)
dependabot[bot] May 30, 2022
dbf0ecd
Bump commander from 9.2.0 to 9.3.0 (#282)
dependabot[bot] May 30, 2022
a5e3c4b
Bump @pulumi/pulumi from 3.33.1 to 3.33.2 (#281)
dependabot[bot] May 30, 2022
eb2af64
Bump @typescript-eslint/eslint-plugin from 5.26.0 to 5.27.0 (#285)
dependabot[bot] May 31, 2022
b0db254
Bump electron-to-chromium from 1.4.141 to 1.4.142 (#286)
dependabot[bot] May 31, 2022
4ee7230
Bump puppeteer from 14.1.1 to 14.1.2 (#287)
dependabot[bot] May 31, 2022
ecbe4d4
Bump @typescript-eslint/parser from 5.26.0 to 5.27.0 (#284)
dependabot[bot] May 31, 2022
24b6034
Bump http-server from 14.1.0 to 14.1.1 (#288)
dependabot[bot] Jun 1, 2022
4042095
Bump @types/react from 18.0.9 to 18.0.10 (#289)
dependabot[bot] Jun 1, 2022
5c31015
Bump @types/node from 17.0.36 to 17.0.38 (#290)
dependabot[bot] Jun 1, 2022
09f431c
Bump aws-sdk from 2.1145.0 to 2.1146.0 (#291)
dependabot[bot] Jun 1, 2022
5ae54be
Bump actions/cache from 3.0.2 to 3.0.3 (#292)
dependabot[bot] Jun 1, 2022
ff0f463
Bump electron-to-chromium from 1.4.142 to 1.4.143 (#294)
dependabot[bot] Jun 2, 2022
339ae32
Bump aws-sdk from 2.1146.0 to 2.1147.0 (#293)
dependabot[bot] Jun 2, 2022
89aa246
Bump @types/jest from 27.5.1 to 28.1.0 (#297)
dependabot[bot] Jun 2, 2022
409937e
Bump core-js-pure from 3.22.7 to 3.22.8 (#295)
dependabot[bot] Jun 2, 2022
8c77102
Bump puppeteer from 14.1.2 to 14.2.0 (#296)
dependabot[bot] Jun 2, 2022
8f30c09
Bump electron-to-chromium from 1.4.143 to 1.4.144 (#299)
dependabot[bot] Jun 3, 2022
a143d13
Bump puppeteer from 14.2.0 to 14.2.1 (#298)
dependabot[bot] Jun 3, 2022
71d5e84
Bump caniuse-lite from 1.0.30001344 to 1.0.30001346 (#300)
dependabot[bot] Jun 3, 2022
b0cdc79
proposal
Zemnmez Jun 3, 2022
6b9d982
Rework project goals a bit
Zemnmez Jun 6, 2022
9d37840
Merge branch 'main' into version-pipelining
Zemnmez Jun 6, 2022
46e437e
Merge pull request #301 from Zemnmez/version-pipelining
Zemnmez Jun 6, 2022
64418d8
restrict copy_to_versioned to main branch
Zemnmez Jun 6, 2022
c365e89
Merge branch 'version-pipelining' of github.com:Zemnmez/monorepo into…
Zemnmez Jun 6, 2022
80ccff9
Run deploy script only on 'versioned' branch
Zemnmez Jun 6, 2022
cb57fcd
Merge branch 'main' into version-pipelining
Zemnmez Jun 6, 2022
2cc78db
Merge pull request #302 from Zemnmez/version-pipelining
Zemnmez Jun 6, 2022
374ae49
Basic versioning code
Zemnmez Jun 6, 2022
a6817dd
Try to make the automatic commit system work
Zemnmez Jun 6, 2022
c88ac33
Merge branch 'version-pipelining' of github.com:Zemnmez/monorepo into…
Zemnmez Jun 6, 2022
cff81da
Merge branch 'main' into version-pipelining
Zemnmez Jun 6, 2022
9f4d206
Remove useless file
Zemnmez Jun 6, 2022
6da9e1c
Merge branch 'version-pipelining' of github.com:Zemnmez/monorepo into…
Zemnmez Jun 6, 2022
a692348
Merge pull request #303 from Zemnmez/version-pipelining
Zemnmez Jun 6, 2022
d565947
Extra rules
Zemnmez Jun 6, 2022
7ba7653
oopsie
Zemnmez Jun 6, 2022
d27d0ed
Merge branch 'main' into version-pipelining
Zemnmez Jun 6, 2022
eb489fc
Merge pull request #305 from Zemnmez/version-pipelining
Zemnmez Jun 6, 2022
b580f09
Re-work merging for PR a bit
Zemnmez Jun 6, 2022
affd702
Merge branch 'version-pipelining' of github.com:Zemnmez/monorepo into…
Zemnmez Jun 6, 2022
7dd254a
Merge pull request #310 from Zemnmez/version-pipelining
Zemnmez Jun 6, 2022
cd81587
Automerge automated PRs
Zemnmez Jun 6, 2022
7dccfd3
Merge branch 'main' into version-pipelining
Zemnmez Jun 6, 2022
2a74bbc
im stupid
Zemnmez Jun 6, 2022
75cb41d
Bump css-functions-list from 3.0.1 to 3.1.0 (#304)
dependabot[bot] Jun 6, 2022
db4cadf
Merge branch 'version-pipelining' of github.com:Zemnmez/monorepo into…
Zemnmez Jun 6, 2022
055dae5
Merge branch 'main' into version-pipelining
Zemnmez Jun 6, 2022
1c640fd
Merge pull request #312 from Zemnmez/version-pipelining
Zemnmez Jun 6, 2022
72fddc9
Bump electron-to-chromium from 1.4.144 to 1.4.146 (#307)
dependabot[bot] Jun 6, 2022
44b1616
Another try :'(
Zemnmez Jun 6, 2022
194b1f2
Merge branch 'version-pipelining' of github.com:Zemnmez/monorepo into…
Zemnmez Jun 6, 2022
cc7b622
Merge pull request #314 from Zemnmez/version-pipelining
Zemnmez Jun 6, 2022
dfad1c4
Bump @types/node from 17.0.38 to 17.0.40 (#313)
dependabot[bot] Jun 6, 2022
72539cf
add bazel rule which hashes files
Zemnmez Jun 6, 2022
011bbfd
Another attempt at fixing copy_to_versioned
Zemnmez Jun 6, 2022
012ccb8
Merge branch 'main' into version-pipelining
Zemnmez Jun 6, 2022
e5d99af
Merge pull request #317 from Zemnmez/version-pipelining
Zemnmez Jun 6, 2022
9ed3550
Bump aws-sdk from 2.1147.0 to 2.1148.0 (#315)
dependabot[bot] Jun 6, 2022
3eba63e
Bump ts-node from 10.8.0 to 10.8.1 (#311)
dependabot[bot] Jun 6, 2022
b308a5d
Bump @types/jest from 28.1.0 to 28.1.1 (#309)
dependabot[bot] Jun 6, 2022
ddbbb3d
Bump @types/react from 18.0.10 to 18.0.12 (#306)
dependabot[bot] Jun 6, 2022
bea0d27
Bump eslint from 8.16.0 to 8.17.0 (#316)
dependabot[bot] Jun 6, 2022
8e590d1
add version testing and bumping
Zemnmez Jun 6, 2022
d690982
maybe it's automatic now??
Zemnmez Jun 6, 2022
6f47874
Merge branch 'version-pipelining' of github.com:Zemnmez/monorepo into…
Zemnmez Jun 6, 2022
e41265d
Merge branch 'main' into version-pipelining
Zemnmez Jun 6, 2022
5154c1c
Merge pull request #319 from Zemnmez/version-pipelining
Zemnmez Jun 6, 2022
8d2d0e3
run the do_not_run_on_main tests on the versioned branch
Zemnmez Jun 6, 2022
fcb5828
Merge branch 'version-pipelining' of github.com:Zemnmez/monorepo into…
Zemnmez Jun 6, 2022
41268c4
Try to fix, yet again, the process of syncing versioned with main
Zemnmez Jun 6, 2022
a201e40
Merge branch 'main' into version-pipelining
Zemnmez Jun 6, 2022
e03eec5
Swap the executable bit on our copy_to_versioned.sh
Zemnmez Jun 6, 2022
f29c484
Merge branch 'version-pipelining' of github.com:Zemnmez/monorepo into…
Zemnmez Jun 6, 2022
1fdce4a
Merge pull request #320 from Zemnmez/version-pipelining
Zemnmez Jun 6, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,6 @@ try-import %workspace%/.bazelrc.user

build --action_env=AWS_ACCESS_KEY_ID --action_env=AWS_SECRET_ACCESS_KEY --action_env=PULUMI_ACCESS_TOKEN
test --action_env=PULUMI_ACCESS_TOKEN

# be careful with this!
test --test_tag_filters=-do_not_run_on_main
14 changes: 14 additions & 0 deletions .github/scripts/copy_to_versioned.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

echo "Open PR to versioned branch (or not, if it was already there)"
echo ""
echo "Skipping failure here too, becuase we don't actually care"
echo "if the PR is already there."
gh pr create -f --head --main --base versioned || true

echo "This ensures we have our commits pushed. We could be up to date"
echo "already. But it doesn't really matter."
git push || true

echo "Setting PR to merge automatically..."
gh pr merge versioned --auto
56 changes: 56 additions & 0 deletions .github/versioning/versioning.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Versioning

A core goal of this monorepo project was to be able to update more frequently the various packages I've developed over time, especially when it comes to updates. I don't want to have to manually update package deps, I'd rather lean on dependabot to do it.

I've previously semi-managed this with [do-sync]: dependabot pull requests are automatically merged if all the tests pass, then, after the dependabot PR is merged, a github action stamps a new version on the repo and another action publishes it to NPM.

[do-sync]: https://github.com/Zemnmez/do-sync

The issues with this are two fold:

1. Github actions (with some restrictions) cannot be triggered by other github actions. It is not entirely clear if what seems to work works 100% of the time.

2. It does not scale. The github action that bumps the version only bumps it in the package.json at the root of the package. This monorepo should eventually have several packages.

## Solutions Considered

### Main-centric flow

In this initially considered approach, when commits are pushed to main, a job runs that bumps versions.

```mermaid
sequenceDiagram
autonumber
Dependabot ->> Main: Dependency PRs
Main ->> Main: (on merge) bump versions
```

The main issue with this approach is that 'main' can't have tests that ensure that versions are correct, or the initial commit will not be possible. Secondarily, it's inelegant to have to separate out kinds of commits such that an infinite version bumping loop doesn't happen.

### Develop-to-main flow

In this alternative flow, instead of having a single deploy and test flow for the monorepo, there is a separate one for the 'main' branch and the 'develop' branch. The 'develop' branch is allowed to have incorrect version numbers, or exclude them completely, and only the main branch has version correctness checks.

When a new commit is pushed to 'develop', a new set of scripts, perhaps in '//.github:postpush' run, generating a new commit that is then pushed to main that contains version information. This is the one I want to go forward with.

```mermaid
sequenceDiagram
autonumber
dependabot ->> develop: Dependency PRs
humans ->> develop: Feature changes
develop ->> main: Postcommit hooks produce new code
main ->> main: deploy scripts
```

## Process
### Introduce new 'versioned' branch
- [ ] Versioned branch copies over all commits from main branch
- [ ] Rule that can be run to bump a version when a set of hashed file(s) changes.
### Introduce new 'versioned tests'
- [ ] Versioned tests, which are able to determine if a major minor
or patch version should be bumped as a result of a change, exist.




[svgshot publish pr]: https://github.com/Zemnmez/monorepo/pull/274
49 changes: 41 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,13 @@ jobs:
automerge:
name: Auto-merge
if: github.actor == 'dependabot[bot]' && github.event_name == 'pull_request'
needs: Test
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
steps:
- name: 'Merge (if dependabot)'
uses: fastify/github-action-merge-dependabot@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
run: gh pr merge versioned --auto


Test:
Expand All @@ -44,7 +41,7 @@ jobs:
with:
node-version: '16'
- name: Restore bazel cache
uses: actions/cache@v3.0.2
uses: actions/cache@v3.0.3
env:
cache-name: bazel-cache
with:
Expand All @@ -57,11 +54,34 @@ jobs:
# bazel generated node_modules
run: bazelisk test //...

TestForMergeToVersioned:
# This runs just the tests that are specified not to run on main
if: github.ref == 'refs/heads/versioned'
name: Tests (for merging into versioned branch)
runs-on: ubuntu-latest
needs: Test
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Restore bazel cache
uses: actions/cache@v3.0.3
env:
cache-name: bazel-cache
with:
path: |
~/.cache/bazelisk
~/.cache/bazel
key: ${{ runner.os }}-${{ env.cache-name }}
- name: All tests
run: bazelisk test //... --test_tag_filters=do_not_run_on_main

deployment:
if: github.event_name == 'push'
if: github.event_name == 'push' && github.ref == 'refs/heads/versioned'
runs-on: ubuntu-latest
environment: production
needs: Test
steps:
- name: Checkout code
Expand All @@ -71,7 +91,7 @@ jobs:
with:
node-version: '16'
- name: Restore bazel cache
uses: actions/cache@v3.0.2
uses: actions/cache@v3.0.3
env:
cache-name: bazel-cache
with:
Expand All @@ -89,3 +109,16 @@ jobs:
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_SECRET }}

copy_to_versioned:
name: Copy commits in main to versioned branch
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: Test
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- run: ./.github/scripts/copy_to_versioned.sh
shell: bash

42 changes: 0 additions & 42 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -56,48 +56,6 @@ load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains")

go_register_toolchains(version = "1.17.2")

load(
"@io_bazel_rules_docker//toolchains/docker:toolchain.bzl",
docker_toolchain_configure = "toolchain_configure",
)
load(
"@io_bazel_rules_docker//repositories:repositories.bzl",
container_repositories = "repositories",
)

container_repositories()

load("@io_bazel_rules_docker//repositories:deps.bzl", container_deps = "deps")

container_deps()

load(
"@io_bazel_rules_docker//toolchains/docker:toolchain.bzl",
docker_toolchain_configure = "toolchain_configure",
)

docker_toolchain_configure(
name = "docker_config",
client_config = "//docker",
docker_flags = [
"--tls",
"--log-level=info",
],
)

load(
"@io_bazel_rules_docker//container:container.bzl",
"container_pull",
)

container_pull(
name = "steamcmd",
digest = "sha256:761c893f5ef7e55b22f7d1d51db7926ad26b60a74b641150b0174cfd9ba86669",
registry = "index.docker.io",
repository = "steamcmd/steamcmd",
tag = "centos",
)

load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")

rules_proto_dependencies()
Expand Down
7 changes: 5 additions & 2 deletions bzl/fix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ FIX_CSS=$(realpath $(rlocation monorepo/css/lint/lint.sh))
FIX_GO=$(realpath $(rlocation go_sdk/bin/gofmt))
FIX_JS=$(realpath $(rlocation npm/eslint/bin/eslint.sh))


echo Fixing CSS files... 1>&2
(cd $BUILD_WORKSPACE_DIRECTORY
git ls-files --cached --modified --other --exclude-standard | uniq | grep .css$ | xargs $FIX_CSS --ignore-path .gitignore --fix
echo Fixing Go files... 1>&2
$FIX_GO -s -w .
$FIX_JS --fix --ignore-pattern 'project/ck3/base_game/*' --ignore-path .gitignore '**/*.ts' '**/*.js' '**/*.tsx' '**/*.json') || true # ignore failures. it fails often
echo Fixing Typescript, Javascript, json files... 1>&2
$FIX_JS --fix --ignore-pattern 'project/ck3/base_game/*' --ignore-path .gitignore "$BUILD_WORKSPACE_DIRECTORY"'/**/*.ts' "$BUILD_WORKSPACE_DIRECTORY"'/**/*.js' "$BUILD_WORKSPACE_DIRECTORY"'/**/*.tsx' "$BUILD_WORKSPACE_DIRECTORY"'/**/*.json') || true # ignore failures. it fails often
echo Fixing bazel files... 1>&2
$FIX_BAZEL --lint=fix -r $INIT_CWD
1 change: 1 addition & 0 deletions bzl/hash/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# no output defined here
50 changes: 50 additions & 0 deletions bzl/hash/rules.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
def _impl(ctx):
# Create actions to generate the three output files.
# Actions are run only when the corresponding file is requested.

inputs = ctx.files.srcs
arguments = [ file.path for file in ctx.files.srcs ]

ctx.actions.run_shell(
outputs = [ctx.outputs.md5],
inputs = inputs,
command = "md5sum $@ > {}".format( ctx.outputs.md5.path),
arguments = arguments,
)

ctx.actions.run_shell(
outputs = [ctx.outputs.sha1],
inputs = inputs,
command = "sha1sum $@ > {}".format( ctx.outputs.sha1.path),
arguments = arguments,
)

ctx.actions.run_shell(
outputs = [ctx.outputs.sha256],
inputs = inputs,
command = "sha256sum $@ > {}".format( ctx.outputs.sha256.path),
arguments = arguments,
)

# By default (if you run `bazel build` on this target, or if you use it as a
# source of another target), only the sha256 is computed.
return DefaultInfo(files = depset([ctx.outputs.sha256]))

_hashes = rule(
implementation = _impl,
attrs = {
"srcs": attr.label_list(mandatory = True, allow_files = True),
"md5": attr.output(),
"sha1": attr.output(),
"sha256": attr.output(),
},
)

def hashes(**kwargs):
name = kwargs["name"]
_hashes(
md5 = "%s.md5" % name,
sha1 = "%s.sha1" % name,
sha256 = "%s.sha256" % name,
**kwargs
)
13 changes: 13 additions & 0 deletions bzl/hash/test/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
load("//bzl/hash:rules.bzl", "hashes")
load("@build_bazel_rules_nodejs//:index.bzl", "generated_file_test")

hashes(
name = "hashes",
srcs = [ "input1.txt", "input2.txt" ]
)

generated_file_test(
name = "version_concat_test",
generated = ":hashes",
src = "expected.txt"
)
2 changes: 2 additions & 0 deletions bzl/hash/test/expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 bzl/hash/test/input1.txt
486ea46224d1bb4fb680f34f7c9ad96a8f24ec88be73ea8e5a6c65260e9cb8a7 bzl/hash/test/input2.txt
1 change: 1 addition & 0 deletions bzl/hash/test/input1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello
1 change: 1 addition & 0 deletions bzl/hash/test/input2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
world
7 changes: 7 additions & 0 deletions bzl/versioning/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
exports_files(
[
"bump.py"
],
visibility = ["//visibility:public"],
)

35 changes: 35 additions & 0 deletions bzl/versioning/bump.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import argparse
import os
import subprocess
import shutil

parser = argparse.ArgumentParser(description="Performs the action of a version bump.")
parser.add_argument('--to_bump_in', help="The version file to bump, as a root-relative path.", type=str)
parser.add_argument('--to_bump_out', help="The version file to bump, as a root-relative path.", type=str)
parser.add_argument('--lockfile_build_label', help="A label that points to the generated (new) version lockfile.", type=str)
parser.add_argument('--lockfile_build_rootpath', help="The path from the repo root that the lockfile is generated into", type=str)
parser.add_argument('--lockfile_out_rootpath', help="The location to place the newly minted version lockfile at.", type=str)

# This happens directly on the real workspace -- also, needs to be
# run from bazel to have this set.
os.chdir(os.environ.get('BUILD_WORKSPACE_DIRECTORY'))

args = parser.parse_args()

number = 0

with open(args.to_bump_in, mode='r', encoding='utf-8') as f:
number = int(f.read())


with open(args.to_bump_out, mode='w', encoding='utf-8') as f:
f.write(str(number+1))

# Once the version has been bumped, generate the new version bump file.
subprocess.run(["bazelisk", "build", args.lockfile_build_label])

# Copy the newly created lockfile across
shutil.copyfile(
os.path.join("dist", "bin", args.lockfile_build_rootpath),
args.lockfile_out_rootpath
)
Loading