diff --git a/.github/workflows/mirror.yml b/.github/workflows/mirror.yml
new file mode 100644
index 00000000..1caf8f26
--- /dev/null
+++ b/.github/workflows/mirror.yml
@@ -0,0 +1,24 @@
+name: Mirror Releases
+on:
+ # Trigger manually in the UI
+ workflow_dispatch:
+ # Trigger daily at 06:45 UTC
+ schedule:
+ # * is a special character in YAML so you have to quote this string
+ - cron: "45 6 * * *"
+
+jobs:
+ mirror:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - run: git checkout -b mirror_releases
+ - run: |
+ ./lint/mirror_ruff.sh
+ bazel run docs:update
+ # NB: make sure "Allow GitHub Actions to create and approve pull requests" is checked
+ # on https://github.com/[my-org/my-repo]/settings/actions
+ - name: create pull request
+ run: "gh pr create --title 'chore: mirror releases' --body 'Auto-generated by .github/workflows/mirror.yml'"
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/docs/ruff.md b/docs/ruff.md
index 45221fdf..2215e6bf 100644
--- a/docs/ruff.md
+++ b/docs/ruff.md
@@ -29,7 +29,7 @@ A repository macro used from WORKSPACE to fetch ruff binaries
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
-| version | a version of ruff that we have mirrored, e.g. v0.1.0
| "v0.1.2"
|
+| version | a version of ruff that we have mirrored, e.g. v0.1.0
| "v0.1.4"
|
diff --git a/lint/BUILD.bazel b/lint/BUILD.bazel
index e5386170..c51e903e 100644
--- a/lint/BUILD.bazel
+++ b/lint/BUILD.bazel
@@ -78,6 +78,7 @@ bzl_library(
srcs = ["ruff.bzl"],
visibility = ["//visibility:public"],
deps = [
+ ":ruff_versions",
"//lint/private:lint_aspect",
"@bazel_tools//tools/build_defs/repo:http.bzl",
"@bazel_tools//tools/build_defs/repo:utils.bzl",
@@ -95,3 +96,9 @@ bzl_library(
"@bazel_tools//tools/build_defs/repo:utils.bzl",
],
)
+
+bzl_library(
+ name = "ruff_versions",
+ srcs = ["ruff_versions.bzl"],
+ visibility = ["//visibility:public"],
+)
diff --git a/lint/mirror_ruff.sh b/lint/mirror_ruff.sh
index c75eb603..d1fc0bcd 100755
--- a/lint/mirror_ruff.sh
+++ b/lint/mirror_ruff.sh
@@ -31,24 +31,35 @@ map(
)[]
'
-
curl > $RELEASES \
--silent \
--header "Accept: application/vnd.github.v3+json" \
- https://api.github.com/repos/${REPOSITORY}/releases?per_page=2
+ https://api.github.com/repos/${REPOSITORY}/releases?per_page=1
jq "$JQ_FILTER" <$RELEASES >$RAW
+# Combine the new versions with the existing ones.
+# New versions should appear first, but existing content should overwrite new
+CURRENT=$(mktemp)
+python3 -c "import json; exec(open('$SCRIPT_DIR/ruff_versions.bzl').read()); print(json.dumps(RUFF_VERSIONS))" > $CURRENT
+OUT=$(mktemp)
+jq --slurp '.[0] * .[1]' $RAW $CURRENT > $OUT
+
FIXED=$(mktemp)
-# Replace URLs with their hash
-for tag in $(jq -r 'keys | .[]' < $RAW); do
+# Replace placeholder sha256 URLs with their content
+for tag in $(jq -r 'keys | .[]' < $OUT); do
# Download checksums for this tag
+ # Note: this is wasteful; we will curl for sha256 files even if the CURRENT content already had resolved them
for sha256url in $(jq --arg tag $tag -r "$SHA256_FILTER" < $RELEASES); do
sha256=$(curl --silent --location $sha256url | awk '{print $1}')
- jq ".[\"$tag\"] |= with_entries(.value = (if .value == \"$sha256url\" then \"$sha256\" else .value end))" < $RAW > $FIXED
- mv $FIXED $RAW
+ jq ".[\"$tag\"] |= with_entries(.value = (if .value == \"$sha256url\" then \"$sha256\" else .value end))" < $OUT > $FIXED
+ mv $FIXED $OUT
done
done
-echo -n "RUFF_VERSIONS = "
-cat $RAW
+# Overwrite the file with updated content
+(
+ echo '"This file is automatically updated by mirror_ruff.sh"'
+ echo -n "RUFF_VERSIONS = "
+ cat $OUT
+)>$SCRIPT_DIR/ruff_versions.bzl
diff --git a/lint/ruff.bzl b/lint/ruff.bzl
index cb9c0510..a339d94a 100644
--- a/lint/ruff.bzl
+++ b/lint/ruff.bzl
@@ -15,6 +15,7 @@ ruff = ruff_aspect(
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load("//lint/private:lint_aspect.bzl", "report_file")
+load(":ruff_versions.bzl", "RUFF_VERSIONS")
_MNEMONIC = "ruff"
@@ -99,46 +100,6 @@ def ruff_aspect(binary, config):
},
)
-# Generated by running ./mirror_ruff.sh
-RUFF_VERSIONS = {
- "v0.1.2": {
- "aarch64-apple-darwin": "99a245e703c1d95afc9b0c2e00bd47bca6ac5c17e6cc046e58bf3f70d6536330",
- "aarch64-pc-windows-msvc": "644390067887b8b0f1bff2805211de6bd006c97ce259760260b27da5356a7db6",
- "aarch64-unknown-linux-gnu": "fef09ce9591c72efd1ef4ce2b0956f1edba21328e29ad865e795d16186a20a06",
- "aarch64-unknown-linux-musl": "a96338c7e96228531a0c2cef39ebe17a215fca3346e2352a00b9f88bc25d5197",
- "armv7-unknown-linux-gnueabihf": "a15894de509ae15eeb48d0121e08536b1b8f16855d88cccb61ecab0c9f4e537d",
- "armv7-unknown-linux-musleabihf": "1c6bf703c489d60ae1db402508d1527292411d9c4fac5d43cf79f08e444e6167",
- "i686-pc-windows-msvc": "aca5b93beac3a76edd7c2ea55f0e09672d2d7f85fcf5c9f4f65c252db643b5b4",
- "i686-unknown-linux-gnu": "fa42d9559589cee38f8ac34c48ce3f9981d204fa2be48fa72945e9c1f026db8c",
- "i686-unknown-linux-musl": "f84d9770205f3b0387ba74dbc62a47f2b234f52fc58ec0e9b8ceb0697035a6cf",
- "powerpc64-unknown-linux-gnu": "b8731842d1d762538a8d41e49853cac4b06b827b0f762bd08e951eb47ec2129c",
- "powerpc64le-unknown-linux-gnu": "36015e708b571465e12ecb655e8165e51ee1d7295800484b94ab21e04c2b17b1",
- "s390x-unknown-linux-gnu": "592fc30494bf63ddb510ac929233a6fa44488273099e064fcf91efc10a3c49ab",
- "x86_64-apple-darwin": "cb339e9684043dae3cf530bca22f532198b9f151b01812f701ed0b85fec95b0a",
- "x86_64-pc-windows-msvc": "5e515c69653469736e76848f401d9f72b4396d8b7be2be77f748109e04542d26",
- "x86_64-unknown-linux-gnu": "cab189b03ed0d882d45691d6cb4a7843e9d8389ba4e2e43cb4616a46ae69545b",
- "x86_64-unknown-linux-musl": "368594d2e96a8a7e14fc610259f1c0a29fab4a84cd061a9373ce415c742df04e",
- },
- "v0.1.1": {
- "aarch64-apple-darwin": "e2444e4c7bda7133a0c47a368993be55f7bbe3c3a68d14be83dca480fe624c5e",
- "aarch64-pc-windows-msvc": "8eb1f83b0e3c9ddd818176fc26065b87b7cb119764c84b109c70d12dff283d21",
- "aarch64-unknown-linux-gnu": "2d56dd602aa62e5e8185971e19c77d6df1e9f14a9190176d8f8212dcde827dde",
- "aarch64-unknown-linux-musl": "ee1117ea3e4c32c92f598592c946bb941cca437cc0ce62bd4e86ea889a081e29",
- "armv7-unknown-linux-gnueabihf": "f0f0b4db10954496149ddb7b6a9d7c16418f386210f3da2823904bde713ba369",
- "armv7-unknown-linux-musleabihf": "894e6f0c5f8a8830fcddf38afa81960fb902211082ef7a1aec00637a2c6e2710",
- "i686-pc-windows-msvc": "a6d5601c9704790409a3540d6dc6cc2a955b234f07df9553e5b4555f9b8ac7e5",
- "i686-unknown-linux-gnu": "9617cd3a921f9d65be973482fae5b888e9e1a9617e779d7d47f3d5f2cdb5c332",
- "i686-unknown-linux-musl": "55d574637179362a2ddf10125d0386054a0cfb3daef0943e9082a87a1a3424e6",
- "powerpc64-unknown-linux-gnu": "143b227ace509cb0a2e2411a5675935d67910f7a280f35931e112e137dc3b894",
- "powerpc64le-unknown-linux-gnu": "94158cc4d4208b29962a6be2245fa391ce158673c4e8c8baa5e9f592c080dc29",
- "s390x-unknown-linux-gnu": "22dcfb5338e546713b86acc1c25d0c11bb72175df652bbd0ad58082c4e273b8b",
- "x86_64-apple-darwin": "da0e3156387a419db6c123fd7d009d7f6153dfb631a17e7aa1551f4d6aec5c7a",
- "x86_64-pc-windows-msvc": "080877770e3494637a01cca05e88ed9a5a450f6129b90053e7f3014ce761f178",
- "x86_64-unknown-linux-gnu": "0f70840c8c10ac8013f734e76977494311b7264a12782bc95be5f9d2e1414176",
- "x86_64-unknown-linux-musl": "2b5555abb21598969be862a05101f35079ff6c72466d74eb22f9a1c773d646d0",
- },
-}
-
def fetch_ruff(version = RUFF_VERSIONS.keys()[0]):
"""A repository macro used from WORKSPACE to fetch ruff binaries
diff --git a/lint/ruff_versions.bzl b/lint/ruff_versions.bzl
new file mode 100644
index 00000000..a66cb667
--- /dev/null
+++ b/lint/ruff_versions.bzl
@@ -0,0 +1,75 @@
+"This file is automatically updated by mirror_ruff.sh"
+RUFF_VERSIONS = {
+ "v0.1.4": {
+ "aarch64-apple-darwin": "d6dc7b1eab34e81d13fa269089df871995aa6b03a9b1f74a936d52541750ee5a",
+ "aarch64-pc-windows-msvc": "308e9e70c60549ca7b4f173c5dd9c1992daf265f3e934698f90baeebefe97c71",
+ "aarch64-unknown-linux-gnu": "188aeb5a9b6a369881ce90042f46edebd8bb220da4c13d1c56046bf7b92239e6",
+ "aarch64-unknown-linux-musl": "9ce29a09ed4922f755f38aeeb5b9534a45f6371e4ca3f112acb78f1303295e71",
+ "armv7-unknown-linux-gnueabihf": "6d9b27d007bf4cd8414dbf19aa6a0085a5054131a8f9a3ef11dfc129c552496f",
+ "armv7-unknown-linux-musleabihf": "b3fcd6b43343c05a2df075aca00b024246fb60cbbc9fbb56e4da75dc4c28e6dc",
+ "i686-pc-windows-msvc": "578ff7a38fb17d7724e546cb28a4be4055982dec496f4bcf6563af8d0574193d",
+ "i686-unknown-linux-gnu": "ceaf84041982b8b6ad3c920be5b1d78f1cc1cfc32332689acf046ddd4e34c380",
+ "i686-unknown-linux-musl": "399ea6ac4aa94bd60e9048531dd9ba8168a88a30421e771ea73a504c92346981",
+ "powerpc64-unknown-linux-gnu": "d08ea41caafa012b46c823232bd5e343b09bad6b6fc7ddde2c3d1cef568f1737",
+ "powerpc64le-unknown-linux-gnu": "88acfbfa3410105257d72315874b2aa74bad319f036fe1ac393b344f3e017887",
+ "s390x-unknown-linux-gnu": "077fba3550bb94707cb57d8316970b195c1b76f62177b50a18e7adc151452297",
+ "x86_64-apple-darwin": "27a2800606b417d8f3102354efd0c09b8e08c94f754aaea9809a74a76e7456da",
+ "x86_64-pc-windows-msvc": "d87c514da69457d7b6b6c9805a0b9e339d4b0bc865be45fc439c703c30d98f37",
+ "x86_64-unknown-linux-gnu": "6b3b27474b4779dc1e6ae1353f4faac00822e3ecd505889162bd3ef91bea3cc4",
+ "x86_64-unknown-linux-musl": "fd0ae41fe4a84e5d99457442da61c0571453eb7ad2791dd6e1603df1883e6664",
+ },
+ "v0.1.3": {
+ "aarch64-apple-darwin": "d7554aebed6483ffd7f60617e2567ae2fc61dccb1a029834c92d4313ee185a33",
+ "aarch64-pc-windows-msvc": "daf5642a0b14d78a7cb1c9e7305d034ee9c6a09071e8507379b5b2686da9150c",
+ "aarch64-unknown-linux-gnu": "86bc7b9f40f3d367a64e4c3243f1298f1dafc0885d22e0aed873552343b3f1cd",
+ "aarch64-unknown-linux-musl": "11a5ba3b94fa72d09f1358eaffe206c83e1447d10f2da58235a792e68a44ed4c",
+ "armv7-unknown-linux-gnueabihf": "288374925e414a3dabbcab335a593359dc4caab4c923a9ef69a8e3a8dc93e747",
+ "armv7-unknown-linux-musleabihf": "7ff675a51ff0fd5a3a372309df49d3776a5c29e42d927da122f51fd3c8b0fd8f",
+ "i686-pc-windows-msvc": "cc24eb8bc24c90ccb6686485c02d3df3a0cec04c9d0491d92a4479dad9064313",
+ "i686-unknown-linux-gnu": "4b9b85974b364cd7bda2a5f9c4a0ed9e9c4a365bcd00673b4f3850c8c2b55ab0",
+ "i686-unknown-linux-musl": "7b04b06e987edcf7229a1ede50de3dcb0295590203c7affb90a24de142cc61cd",
+ "powerpc64-unknown-linux-gnu": "45533eb90d0a92bc5ae7dc67303698cf43217cea28f53bbd5ac09d372f4cf489",
+ "powerpc64le-unknown-linux-gnu": "6b4b5bc9163883c51844fde3acc58599548f4561a5dcbd4e78cd8ca3a8260d56",
+ "s390x-unknown-linux-gnu": "dcdd65d5aa52c389b03ae9aa2d728da89b6aa6561e40e93cc846f2ae63e2bb43",
+ "x86_64-apple-darwin": "55726dadf43771e97b61b79165f2bfb8071799988bc2d9b4b3eff4da98aa994b",
+ "x86_64-pc-windows-msvc": "605e44ed4e7ae718dca298584270816c1d8c6eddcc1bc96b17c37d5938706ddc",
+ "x86_64-unknown-linux-gnu": "9b462ec7ea6acf3d5c02f0ce1060d98376778e2a887b4315a4964e956fab5448",
+ "x86_64-unknown-linux-musl": "ee8bf6915af2a584ea024ce8669b1aeca03928aadcbb25c8f45359acc1992c47",
+ },
+ "v0.1.2": {
+ "aarch64-apple-darwin": "99a245e703c1d95afc9b0c2e00bd47bca6ac5c17e6cc046e58bf3f70d6536330",
+ "aarch64-pc-windows-msvc": "644390067887b8b0f1bff2805211de6bd006c97ce259760260b27da5356a7db6",
+ "aarch64-unknown-linux-gnu": "fef09ce9591c72efd1ef4ce2b0956f1edba21328e29ad865e795d16186a20a06",
+ "aarch64-unknown-linux-musl": "a96338c7e96228531a0c2cef39ebe17a215fca3346e2352a00b9f88bc25d5197",
+ "armv7-unknown-linux-gnueabihf": "a15894de509ae15eeb48d0121e08536b1b8f16855d88cccb61ecab0c9f4e537d",
+ "armv7-unknown-linux-musleabihf": "1c6bf703c489d60ae1db402508d1527292411d9c4fac5d43cf79f08e444e6167",
+ "i686-pc-windows-msvc": "aca5b93beac3a76edd7c2ea55f0e09672d2d7f85fcf5c9f4f65c252db643b5b4",
+ "i686-unknown-linux-gnu": "fa42d9559589cee38f8ac34c48ce3f9981d204fa2be48fa72945e9c1f026db8c",
+ "i686-unknown-linux-musl": "f84d9770205f3b0387ba74dbc62a47f2b234f52fc58ec0e9b8ceb0697035a6cf",
+ "powerpc64-unknown-linux-gnu": "b8731842d1d762538a8d41e49853cac4b06b827b0f762bd08e951eb47ec2129c",
+ "powerpc64le-unknown-linux-gnu": "36015e708b571465e12ecb655e8165e51ee1d7295800484b94ab21e04c2b17b1",
+ "s390x-unknown-linux-gnu": "592fc30494bf63ddb510ac929233a6fa44488273099e064fcf91efc10a3c49ab",
+ "x86_64-apple-darwin": "cb339e9684043dae3cf530bca22f532198b9f151b01812f701ed0b85fec95b0a",
+ "x86_64-pc-windows-msvc": "5e515c69653469736e76848f401d9f72b4396d8b7be2be77f748109e04542d26",
+ "x86_64-unknown-linux-gnu": "cab189b03ed0d882d45691d6cb4a7843e9d8389ba4e2e43cb4616a46ae69545b",
+ "x86_64-unknown-linux-musl": "368594d2e96a8a7e14fc610259f1c0a29fab4a84cd061a9373ce415c742df04e",
+ },
+ "v0.1.1": {
+ "aarch64-apple-darwin": "e2444e4c7bda7133a0c47a368993be55f7bbe3c3a68d14be83dca480fe624c5e",
+ "aarch64-pc-windows-msvc": "8eb1f83b0e3c9ddd818176fc26065b87b7cb119764c84b109c70d12dff283d21",
+ "aarch64-unknown-linux-gnu": "2d56dd602aa62e5e8185971e19c77d6df1e9f14a9190176d8f8212dcde827dde",
+ "aarch64-unknown-linux-musl": "ee1117ea3e4c32c92f598592c946bb941cca437cc0ce62bd4e86ea889a081e29",
+ "armv7-unknown-linux-gnueabihf": "f0f0b4db10954496149ddb7b6a9d7c16418f386210f3da2823904bde713ba369",
+ "armv7-unknown-linux-musleabihf": "894e6f0c5f8a8830fcddf38afa81960fb902211082ef7a1aec00637a2c6e2710",
+ "i686-pc-windows-msvc": "a6d5601c9704790409a3540d6dc6cc2a955b234f07df9553e5b4555f9b8ac7e5",
+ "i686-unknown-linux-gnu": "9617cd3a921f9d65be973482fae5b888e9e1a9617e779d7d47f3d5f2cdb5c332",
+ "i686-unknown-linux-musl": "55d574637179362a2ddf10125d0386054a0cfb3daef0943e9082a87a1a3424e6",
+ "powerpc64-unknown-linux-gnu": "143b227ace509cb0a2e2411a5675935d67910f7a280f35931e112e137dc3b894",
+ "powerpc64le-unknown-linux-gnu": "94158cc4d4208b29962a6be2245fa391ce158673c4e8c8baa5e9f592c080dc29",
+ "s390x-unknown-linux-gnu": "22dcfb5338e546713b86acc1c25d0c11bb72175df652bbd0ad58082c4e273b8b",
+ "x86_64-apple-darwin": "da0e3156387a419db6c123fd7d009d7f6153dfb631a17e7aa1551f4d6aec5c7a",
+ "x86_64-pc-windows-msvc": "080877770e3494637a01cca05e88ed9a5a450f6129b90053e7f3014ce761f178",
+ "x86_64-unknown-linux-gnu": "0f70840c8c10ac8013f734e76977494311b7264a12782bc95be5f9d2e1414176",
+ "x86_64-unknown-linux-musl": "2b5555abb21598969be862a05101f35079ff6c72466d74eb22f9a1c773d646d0",
+ },
+}