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

Add a GH workflow to update crates versions weekly #40

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
38 changes: 38 additions & 0 deletions .github/workflows/update-crates-versions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Update crates versions

defaults:
run:
shell: bash

on:
schedule:
# Every Sunday at 00:00
- cron: '0 0 * * 0'
workflow_dispatch:

jobs:
updateversions:
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
with:
fetch-depth: 1
- name: Setup rust toolchain
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af
with:
toolchain: stable
default: true
- name: Retrieve newest versions of dependencies
run: ./bin/update-crates-versions.sh
- name: Create pull request
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would maybe split this one step into several steps, like https://github.com/exercism/org-wide-files/blob/main/.github/workflows/sync-rest.yml#L303 That makes it easier to debug what went wrong when a build fails.

run: |
git config --global user.email "[email protected]"
git config --global user.name "Exercism Bot"
Comment on lines +30 to +31
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SaschaMann will this work with the GITHUB_TOKEN passed in not being the token of the Exercism bot? And does it even need to be the Exercism Bot user here?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might show up as unverified but generally the git name and email can be whatever. For consistency, you might want to set these to match Exercism Bot elsewhere, or at least point it either at an obvious dummy email address or one that actually works, not one that looks like it may work but likely doesn't.

https://github.com/exercism/org-wide-files/blob/601d9a5924d470499451e441371f9b3bd11caef0/.github/workflows/sync-rest.yml#L23-L24

git checkout -b update-crates-versions
git add local-registry/Cargo.toml
git commit -m "Update crates versions"
git push -u origin update-crates-versions
gh pr create --title "Update crates versions" --body "This is an automated pull request"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5 changes: 1 addition & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ RUN rm src/lib.rs
COPY src/* src/
# build the executable
RUN cargo build --release
COPY bin/generate-registry.sh ${wd}/bin/
# download jq
RUN curl -L -o /usr/local/bin/jq "${JQ_URL}" \
&& chmod +x /usr/local/bin/jq
Expand All @@ -34,7 +33,7 @@ RUN curl -L -o clr.tar.gz "${CLR_URL}" \
# download popular crates to local registry
WORKDIR /local-registry
COPY local-registry/* ./
RUN ${wd}/bin/generate-registry.sh
RUN cargo generate-lockfile && cargo local-registry --sync Cargo.lock .

# As of Dec 2019, we need to use the nightly toolchain to get JSON test output
FROM rustlang/rust:nightly AS test
Expand All @@ -53,6 +52,4 @@ replace-with = "local-registry"\n\
local-registry = "/opt/test-runner/local-registry/"\n' >> $CARGO_HOME/config.toml
# set entrypoint
COPY bin/run.sh bin
COPY --from=build /usr/local/cargo/bin/cargo-local-registry /usr/local/cargo/bin/
COPY bin/generate-registry.sh bin
ENTRYPOINT ["bin/run.sh"]
23 changes: 0 additions & 23 deletions bin/generate-registry.sh

This file was deleted.

13 changes: 13 additions & 0 deletions bin/update-crates-versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

MANIFEST=local-registry/Cargo.toml
DEP_LINE=$(grep -n "\[dependencies\]" $MANIFEST | cut -d : -f 1)
DEPS=$(tail -n +$(($DEP_LINE + 1)) $MANIFEST)

while IFS= read -r line
do
crate=$(echo "$line" | awk -F"[ ]+" '{print $1}')
>&2 echo "Retrieving latest version of $crate..."
latest_version=$(cargo search "$crate" | head -n 1 | awk -F"[ ]+" '{print $1 " = " $3}' | sed 's/"/\\"/g')
sed -i "s/^$crate =.*/$latest_version/" $MANIFEST
done <<< "$DEPS"
231 changes: 231 additions & 0 deletions local-registry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,234 @@ edition = "2021"
path = "dummy.rs"

[dependencies]
unicode-segmentation = "1.8.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's great to have the dependencies listed here explicitly 👍

chrono = "0.4.19"
itertools = "0.10.3"
rand = "0.8.4"
regex = "1.5.4"
lazy_static = "1.4.0"
rayon = "1.5.1"
time = "0.3.5"
num = "0.4.0"
unicode-reverse = "1.0.8"
maplit = "1.0.2"
crossbeam = "0.8.1"
num-traits = "0.2.14"
primes = "0.3.0"
num-bigint = "0.4.3"
modulo = "0.1.2"
criterion = "0.3.5"
num-integer = "0.1.44"
crossbeam-utils = "0.8.5"
bit-vec = "0.6.3"
strum = "0.23.0"
strum_macros = "0.23.1"
primal = "0.3.0"
once_cell = "1.8.0"
failure = "0.1.8"
counter = "0.5.2"
permutator = "0.4.0"
rstest = "0.11.0"
crossbeam-channel = "0.5.1"
bitflags = "1.3.2"
permutohedron = "0.2.4"
num-derive = "0.3.3"
ndarray = "0.15.4"
anyhow = "1.0.51"
nom = "7.1.0"
threadpool = "1.8.1"
cached = "0.26.2"
unicase = "2.6.0"
phf = "0.10.0"
libmath = "0.2.1"
unicode-normalization = "0.1.19"
rstest_reuse = "0.1.3"
petgraph = "0.6.0"
im = "15.0.0"
hexlit = "0.5.3"
enum-iterator = "0.7.0"
boolinator = "2.4.0"
uuid = "1.0.0-alpha.1"
num_enum = "0.5.4"
duplicate = "0.3.0"
divrem = "1.0.0"
pest = "2.1.3"
modinverse = "0.1.1"
dashmap = "4.0.2"
bit-set = "0.5.2"
bimap = "0.6.1"
voca_rs = "1.14.0"
unic-segment = "0.9.0"
thiserror = "1.0.30"
multiset = "0.0.5"
kmp = "0.1.1"
gcd = "2.0.2"
fnv = "1.0.7"
derivative = "2.2.0"
ascii = "1.0.0"
unicode_reader = "1.0.2"
unic-char-range = "0.9.0"
structopt = "0.3.25"
scan_fmt = "0.2.6"
pretty_assertions = "1.0.0"
pest_derive = "2.1.0"
multimap = "0.8.3"
try_opt = "0.2.0"
integer-sqrt = "0.1.5"
int-enum = "0.4.0"
indexmap = "1.7.0"
hashers = "1.0.1"
grapheme = "0.0.0"
factorial = "0.2.1"
eval = "0.4.3"
derive_more = "0.99.17"
counted-array = "0.1.2"
case = "1.0.0"
bitvec = "1.0.0-rc1"
arrayvec = "0.7.2"
Inflector = "0.11.4"
watch = "0.2.0"
stringsort = "2.0.0"
serde = "1.0.130"
rusqlite = "0.26.1"
reikna = "0.12.3"
modexp = "0.2.2"
mod_exp = "1.0.1"
lazysort = "0.2.1"
evalexpr = "6.6.0"
enumflags2 = "0.7.1"
enum_derive = "0.1.7"
custom_derive = "0.1.7"
char_stream = "0.1.8"
bytecount = "0.6.2"
bencher = "0.1.5"
unzip-n = "0.1.2"
unic-normal = "0.9.0"
transpose = "0.2.1"
test-case = "1.2.1"
subslice = "0.2.3"
strfmt = "0.1.6"
slow_primes = "0.1.14"
serde_derive = "1.0.130"
say-number = "1.0.0"
rustversion = "1.0.6"
rs_poker = "2.0.0-alpha.1"
recur-fn = "2.2.0"
readonly = "0.2.0"
rand_chacha = "0.3.1"
ramp = "0.6.0"
quickcheck_macros = "1.0.0"
quickcheck = "1.0.3"
proptest = "1.0.0"
prime_tools = "0.3.4"
peg = "0.7.0"
pcre = "0.2.3"
ordered-float = "2.8.0"
onig = "6.3.1"
num_cpus = "1.13.0"
luhn = "1.0.1"
linked_hash_set = "0.1.4"
linked-hash-map = "0.5.4"
libm = "0.2.1"
inflections = "1.1.1"
indicatif = "0.17.0-beta.1"
imageproc = "0.22.0"
image = "0.23.14"
if_chain = "1.0.2"
hashbag = "0.1.4"
generational-arena = "0.2.8"
frunk = "0.4.0"
factor = "0.4.0"
enum-primitive-derive = "0.2.2"
either = "1.6.1"
digits_iterator = "0.1.0"
csv = "1.1.6"
conv = "0.3.3"
compare = "0.1.0"
char-iter = "0.1.0"
caseless = "0.2.1"
binomial-iter = "0.1.0"
bigint = "4.4.3"
bigdecimal = "0.3.0"
async-std = "1.10.0"
async-channel = "1.6.1"
assert_float_eq = "1.1.3"
array_tool = "1.0.3"
z3 = "0.11.2"
xvii = "0.4.1"
workerpool = "1.2.0"
unidecode = "0.3.0"
unicode-case-mapping = "0.2.0"
unic-langid = "0.9.0"
tramp = "0.3.0"
tinyset = "0.4.6"
stringreader = "0.1.1"
static_assertions = "1.1.0"
spinning_top = "0.2.4"
sparse-bitfield = "0.11.0"
sliding_windows = "3.0.0"
simplelog = "0.11.0"
simple_parallel = "0.3.0"
serial_test = "0.5.1"
scoped_threadpool = "0.1.9"
scoped-pool = "1.0.0"
rustc-hash = "1.1.0"
rug = "1.14.0"
reduce = "0.1.4"
queues = "1.1.0"
pprof = "0.6.1"
phf_macros = "0.10.0"
pathfinding = "2.2.2"
out = "6.1.0"
numtoa = "0.2.4"
num-format = "0.4.0"
num-digitize = "0.4.2"
mustache = "0.9.0"
memoize = "0.1.9"
macro-attr = "0.2.0"
log = "0.4.14"
lexical-sort = "0.3.1"
left-pad = "1.0.1"
lalrpop-util = "0.19.6"
itoa = "0.4.8"
indoc = "1.0.3"
incremental-topo = "0.1.2"
humantime = "2.1.0"
hashbrown = "0.11.2"
genawaiter = "0.99.1"
futures-core = "0.3.18"
free-ranges = "1.0.7"
foreach = "0.3.0"
fluent = "0.16.0"
flamer = "0.4.0"
flame = "0.2.2"
flagset = "0.4.2"
fixedbitset = "0.4.0"
fasteval = "0.2.4"
fancy-regex = "0.7.1"
failure_derive = "0.1.8"
enumset = "1.0.8"
enum-utils = "0.1.2"
encode_unicode = "0.3.6"
easybench = "1.1.0"
divisors = "0.2.1"
dia-time = "6.1.0"
deunicode = "1.3.1"
defaultmap = "0.5.0"
cranelift-simplejit = "0.68.0"
cranelift-module = "0.78.0"
cranelift = "0.78.0"
cow-utils = "0.1.2"
convert_case = "0.4.0"
const_fn_assert = "0.1.2"
clap = "3.0.0-beta.5"
chomp = "0.3.1"
chashmap = "2.2.2"
change-case = "0.2.0"
cast = "0.3.0"
case_insensitive_hashmap = "1.0.0"
bstr = "0.2.17"
binary-heap-plus = "0.4.1"
as-slice = "0.2.1"
arr_macro = "0.1.3"
alloc_counter = "0.0.4"