diff --git a/.github/scripts/copy_to_versioned.sh b/.github/scripts/copy_to_versioned.sh index f3bcfb9a08..6b06eecd24 100755 --- a/.github/scripts/copy_to_versioned.sh +++ b/.github/scripts/copy_to_versioned.sh @@ -1,14 +1,12 @@ #!/usr/bin/env bash +git push + 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 +gh pr create -f --base versioned || git push -f echo "Setting PR to merge automatically..." gh pr merge --auto --merge diff --git a/.github/scripts/fix_any_failing_fixable_tests.sh b/.github/scripts/fix_any_failing_fixable_tests.sh new file mode 100644 index 0000000000..f40687a702 --- /dev/null +++ b/.github/scripts/fix_any_failing_fixable_tests.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +BAZEL_CMD="${BAZEL_CMD:-yarn -s run bazel}" + +FIXER_TARGETS=$($BAZEL_CMD test \ + --test_summary=terse \ + --test_tag_filters=fixable \ + $@ //... | \ + awk '{print $1}' | \ + sed 's/$/.fix/g' | \ + sed -n '/^\/\//p' ) + +# Run all fixers +$BAZEL_CMD run $FIXER_TARGETS diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4d15397c21..0a3efe8a71 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -86,7 +86,7 @@ jobs: ~/.cache/bazelisk ~/.cache/bazel key: ${{ runner.os }}-${{ env.cache-name }} - - name: All tests + - name: Special 'versioned' branch tests run: bazelisk test //... --test_tag_filters=do_not_run_on_main deployment: @@ -129,7 +129,30 @@ jobs: uses: actions/checkout@v3 with: fetch-depth: 0 - - run: ./.github/scripts/copy_to_versioned.sh + - name: Restore bazel cache + uses: actions/cache@v3.0.4 + env: + cache-name: bazel-cache + with: + path: | + ~/.cache/bazelisk + ~/.cache/bazel + key: ${{ runner.os }}-${{ env.cache-name }} + - name: Run all tests that are fixable, and perform fixes. + # bash prefix just because vscode for web can't chmod + run: bash ./.github/scripts/fix_any_failing_fixable_tests.sh --test_tag_filters=do_not_run_on_main + env: + BAZEL_CMD: bazelisk + - name: Run special 'versioned' branch tests + run: bazelisk test //... --test_tag_filters=do_not_run_on_main + - name: Commit any changes + run: | + git config user.name github-actions + git config user.email github-actions@github.com + git add . + git commit -am "Automatic fixes." + - name: Copy to versioned branch + run: ./.github/scripts/copy_to_versioned.sh shell: bash env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/bzl/versioning/rules.bzl b/bzl/versioning/rules.bzl index 6ad905ed92..aa02cc54f3 100644 --- a/bzl/versioning/rules.bzl +++ b/bzl/versioning/rules.bzl @@ -60,7 +60,7 @@ def bump_on_change_test(name, srcs = [], version_lock = None, version = None, ru name = name, generated = hashes_name, src = version_lock, - tags = tags + ["version_check"], + tags = tags + ["version_check", "fixable"], ) py_binary( @@ -81,3 +81,8 @@ def bump_on_change_test(name, srcs = [], version_lock = None, version = None, ru "$(rootpath " + version_lock + ")", ], ) + + native.alias( + name = name + ".fix", + actual = name + ".bump", + ) \ No newline at end of file