From 8eb9052c4c580b828371144b5a84a990268fe729 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sat, 14 Dec 2019 15:43:04 -0500 Subject: [PATCH 01/21] don't ignore DB cache if local cache is empty greatly speeds up builds using --skip + docker-compose, for which the local cache will _always_ be empty --- src/docbuilder/mod.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/docbuilder/mod.rs b/src/docbuilder/mod.rs index f07844b74..c6e5e8b7c 100644 --- a/src/docbuilder/mod.rs +++ b/src/docbuilder/mod.rs @@ -44,12 +44,10 @@ impl DocBuilder { let path = PathBuf::from(&self.options.prefix).join("cache"); let reader = fs::File::open(path).map(|f| BufReader::new(f)); - if reader.is_err() { - return Ok(()); - } - - for line in reader.unwrap().lines() { - self.cache.insert(line?); + if let Ok(reader) = reader { + for line in reader.lines() { + self.cache.insert(line?); + } } self.load_database_cache()?; From 57e270f29031061445a6d3194aeafca369130cbd Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Thu, 12 Dec 2019 16:18:05 -0500 Subject: [PATCH 02/21] don't ignore passing tests --- src/utils/copy.rs | 1 - src/web/badge/badge.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/src/utils/copy.rs b/src/utils/copy.rs index bc47c78f7..21b29356c 100644 --- a/src/utils/copy.rs +++ b/src/utils/copy.rs @@ -89,7 +89,6 @@ mod test { use super::*; #[test] - #[ignore] fn test_copy_dir() { let destination = tempdir::TempDir::new("cratesfyi").unwrap(); diff --git a/src/web/badge/badge.rs b/src/web/badge/badge.rs index d59a97bf2..a2f3c037d 100644 --- a/src/web/badge/badge.rs +++ b/src/web/badge/badge.rs @@ -166,7 +166,6 @@ mod tests { } #[test] - #[ignore] fn test_to_svg() { use std::fs::File; use std::io::Write; From 82c4091b4432fd7c2c84d50f8febd54790103ac2 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Fri, 13 Dec 2019 13:00:34 -0500 Subject: [PATCH 03/21] add more tests using a shell script this is the quick and dirty way, but it's better than having no tests at all. --- .github/workflows/ci.yml | 11 +++++ test.sh | 95 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100755 test.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 76b5209a7..f718ca212 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,6 +22,17 @@ jobs: - name: Test docs.rs run: cargo test -- --test-threads=1 + - name: Install HTML parser + # TODO: don't hardcode this for amd64 + run: > + wget https://github.com/ericchiang/pup/releases/download/v0.4.0/pup_v0.4.0_linux_arm64.zip && + [ "$(sha256sum pup_v0.4.0_linux_arm64.zip)" = ec3d29e9fb375b87ac492c8b546ad6be84b0c0b49dab7ff4c6b582eac71ba01c ] && + unzip pup_v0.4.0_linux_arm64.zip && + mv pup /usr/local/bin + + - name: Test docs.rs more thoroughly + run: ./test.sh + docker: name: Docker runs-on: ubuntu-latest diff --git a/test.sh b/test.sh new file mode 100755 index 000000000..049bfc0f9 --- /dev/null +++ b/test.sh @@ -0,0 +1,95 @@ +#!/usr/bin/env bash +# test script for docs.rs +# requires the following tools installed: +# - docker-compose +# - curl +# - pup (https://github.com/EricChiang/pup) + +set -euv + +docker-compose build +# this never exits, run it in the background +# TODO: catch errors if `up` failed +docker-compose up --build -d + +# build a crate and store it in the database +build() { + docker-compose run web build crate "$@" +} + +# build a few types of crates +# library +build rand 0.7.2 +# binary +build bat 0.12.1 +# proc-macro +build rstest 0.4.1 +# multiple crate types +build sysinfo 0.10.0 +# renamed crate +build constellation-rs 0.1.8 +# used later for latest version +build rand 0.7.1 +build pyo3 0.2.7 +build pyo3 0.8.3 + +HOST=localhost:3000 + +# small wrapper around curl to hide extraneous output +curl() { + command curl -s -o /dev/null +} + +# give the HTTP status of a page hosted locally +status() { + curl -I -w %{http_code} "$HOST/$1" +} + +# give the URL a page hosted locally redirects to +# if the page does not redirect, returns the same page it was given +redirect() { + curl -IL -w %{url_effective} "$HOST/$1" +} + +version_redirect() { + curl "$1" | pup "form ul li a.warn attr{href}" +} + +assert_status() { + [ "$(status "$1")" = "$2" ] +} +assert_redirect() { + [ "$(redirect "$1")" = "$HOST/$2" ] +} +assert_version_redirect() { + [ "$(version_redirect "$1")" = "$HOST/$2" ] +} + +# make sure the crates built successfully +for crate in /rand/0.7.2/rand /rstest/0.12.1/rstest /sysinfo/0.10.0/sysinfo /constellation-rs/0.1.8/constellation; do + assert_status "$crate" 200 +done + +assert_redirect /bat/0.12.1/bat /crate/bat/0.12.1 + +# make sure it shows source code for rustdoc +assert_status /constellation-rs/0.1.8/src/constellation/lib.rs.html 200 +# make sure it shows source code for docs.rs +assert_status /crate/constellation-rs/0.1.8/source/ 200 +# with or without trailing slashes +assert_status /crate/constellation-rs/0.1.8/source 200 + +# check 'Go to latest version' keeps the current page +assert_version_redirect /rand/0.6.5/rand/trait.Rng.html \ + /rand/0.7.2/rand/trait.Rng.html +# and the current platform +assert_version_redirect /rand/0.6.5/x86_64-unknown-linux-gnu/rand/fn.thread_rng.html \ + /rand/0.7.2/x86_64-unknown-linux-gnu/rand/fn.thread_rng.html +# latest version searches for deleted items +assert_version_redirect /rand/0.6.5/rand/rngs/struct.JitterRng.html \ + "/rand/0.7.2/rand/?search=JitterRng" +# for renamed items +assert_version_redirect /pyo3/0.2.7/pyo3/exc/struct.ArithmeticError.html \ + "/pyo3/0.8.3/pyo3/?search=ArithmeticError" + +docker-compose down From af0062eda85085654882e9885e245ed86654897c Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Fri, 13 Dec 2019 14:44:44 -0500 Subject: [PATCH 04/21] arm != amd --- .github/workflows/ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f718ca212..9cc775723 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,8 +25,9 @@ jobs: - name: Install HTML parser # TODO: don't hardcode this for amd64 run: > - wget https://github.com/ericchiang/pup/releases/download/v0.4.0/pup_v0.4.0_linux_arm64.zip && - [ "$(sha256sum pup_v0.4.0_linux_arm64.zip)" = ec3d29e9fb375b87ac492c8b546ad6be84b0c0b49dab7ff4c6b582eac71ba01c ] && + wget https://github.com/ericchiang/pup/releases/download/v0.4.0/pup_v0.4.0_linux_amd64.zip && + [ "$(sha256sum pup_v0.4.0_linux_amd64.zip | cut -d ' ' -f 1)" = + ec3d29e9fb375b87ac492c8b546ad6be84b0c0b49dab7ff4c6b582eac71ba01c ] && unzip pup_v0.4.0_linux_arm64.zip && mv pup /usr/local/bin From c40074af725cdcaf14ff5569a9773f889e4a3799 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Fri, 13 Dec 2019 14:44:58 -0500 Subject: [PATCH 05/21] don't rebuild crate unless it doesn't already exist This shouldn't affect the CI at all since it has a new image every time, but greatly speeds up local development. --- test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test.sh b/test.sh index 049bfc0f9..d977801fc 100755 --- a/test.sh +++ b/test.sh @@ -12,9 +12,9 @@ docker-compose build # TODO: catch errors if `up` failed docker-compose up --build -d -# build a crate and store it in the database +# build a crate and store it in the database if it does not already exist build() { - docker-compose run web build crate "$@" + docker-compose run web build --skip --skip-if-log-exists crate "$@" } # build a few types of crates From 24453314dc0fca01b6e078d5399cabc43ca62d98 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Fri, 13 Dec 2019 14:45:36 -0500 Subject: [PATCH 06/21] pass arguments to curl oops! --- test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.sh b/test.sh index d977801fc..88aaf6db7 100755 --- a/test.sh +++ b/test.sh @@ -37,7 +37,7 @@ HOST=localhost:3000 # small wrapper around curl to hide extraneous output curl() { - command curl -s -o /dev/null + command curl -s -o /dev/null "$@" } # give the HTTP status of a page hosted locally From 4c639b3b119cdc06dee78eeb7752c0b91a7b3664 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Fri, 13 Dec 2019 14:56:58 -0500 Subject: [PATCH 07/21] fix arm -> amd again --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9cc775723..e6e171ea7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,7 +28,7 @@ jobs: wget https://github.com/ericchiang/pup/releases/download/v0.4.0/pup_v0.4.0_linux_amd64.zip && [ "$(sha256sum pup_v0.4.0_linux_amd64.zip | cut -d ' ' -f 1)" = ec3d29e9fb375b87ac492c8b546ad6be84b0c0b49dab7ff4c6b582eac71ba01c ] && - unzip pup_v0.4.0_linux_arm64.zip && + unzip pup_v0.4.0_linux_amd64.zip && mv pup /usr/local/bin - name: Test docs.rs more thoroughly From 06b51302ab62c5fbdb4a6afcd6a397c352ecf838 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Fri, 13 Dec 2019 15:13:37 -0500 Subject: [PATCH 08/21] remove duplicate slashes --- test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test.sh b/test.sh index 88aaf6db7..17edf72cb 100755 --- a/test.sh +++ b/test.sh @@ -42,13 +42,13 @@ curl() { # give the HTTP status of a page hosted locally status() { - curl -I -w %{http_code} "$HOST/$1" + curl -I -w %{http_code} "$HOST$1" } # give the URL a page hosted locally redirects to # if the page does not redirect, returns the same page it was given redirect() { - curl -IL -w %{url_effective} "$HOST/$1" + curl -IL -w %{url_effective} "$HOST$1" } version_redirect() { From 147b15ac64b88be1d673f48ee4615311f06edfb5 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Fri, 13 Dec 2019 15:27:53 -0500 Subject: [PATCH 09/21] don't require sudo access --- .github/workflows/ci.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e6e171ea7..bc2dc3d30 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,11 +28,10 @@ jobs: wget https://github.com/ericchiang/pup/releases/download/v0.4.0/pup_v0.4.0_linux_amd64.zip && [ "$(sha256sum pup_v0.4.0_linux_amd64.zip | cut -d ' ' -f 1)" = ec3d29e9fb375b87ac492c8b546ad6be84b0c0b49dab7ff4c6b582eac71ba01c ] && - unzip pup_v0.4.0_linux_amd64.zip && - mv pup /usr/local/bin + unzip pup_v0.4.0_linux_amd64.zip - name: Test docs.rs more thoroughly - run: ./test.sh + run: PATH="$PATH:." ./test.sh docker: name: Docker From 275d479548df9b381776c0cff15f25965c1e4964 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Fri, 13 Dec 2019 15:44:36 -0500 Subject: [PATCH 10/21] add .env file --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bc2dc3d30..32066f538 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,7 @@ jobs: unzip pup_v0.4.0_linux_amd64.zip - name: Test docs.rs more thoroughly - run: PATH="$PATH:." ./test.sh + run: cp .env.sample .env && PATH="$PATH:." ./test.sh docker: name: Docker From 34e705d7510002c6aecca5b3c24badc7424f485c Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sat, 14 Dec 2019 15:12:01 -0500 Subject: [PATCH 11/21] cache .rustwide directory --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 32066f538..ffa5b38dc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,6 +30,12 @@ jobs: ec3d29e9fb375b87ac492c8b546ad6be84b0c0b49dab7ff4c6b582eac71ba01c ] && unzip pup_v0.4.0_linux_amd64.zip + - name: Cache Rustwide directory + uses: actions/cache@v1 + with: + key: always + path: .rustwide-docker + - name: Test docs.rs more thoroughly run: cp .env.sample .env && PATH="$PATH:." ./test.sh From df91fc5d78435736250bb88a506a3e2e4ded9cea Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sat, 14 Dec 2019 17:20:08 -0500 Subject: [PATCH 12/21] fix broken test suite --- test.sh | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/test.sh b/test.sh index 17edf72cb..891ecda9b 100755 --- a/test.sh +++ b/test.sh @@ -10,7 +10,7 @@ set -euv docker-compose build # this never exits, run it in the background # TODO: catch errors if `up` failed -docker-compose up --build -d +docker-compose up -d # build a crate and store it in the database if it does not already exist build() { @@ -29,17 +29,23 @@ build sysinfo 0.10.0 # renamed crate build constellation-rs 0.1.8 # used later for latest version -build rand 0.7.1 +build rand 0.6.5 build pyo3 0.2.7 build pyo3 0.8.3 -HOST=localhost:3000 +HOST=http://localhost:3000 # small wrapper around curl to hide extraneous output curl() { command curl -s -o /dev/null "$@" } +# exit with a failure message +die() { + echo "$@" + exit 1 +} + # give the HTTP status of a page hosted locally status() { curl -I -w %{http_code} "$HOST$1" @@ -52,22 +58,27 @@ redirect() { } version_redirect() { - curl "$1" | pup "form ul li a.warn attr{href}" + command curl -s "$HOST$1" | pup "form ul li a.warn attr{href}" +} + +assert_eq() { + [ "$1" = "$2" ] || die "expected '$1' to be '$2'" } assert_status() { - [ "$(status "$1")" = "$2" ] + assert_eq "$(status "$1")" "$2" } assert_redirect() { - [ "$(redirect "$1")" = "$HOST/$2" ] + assert_eq "$(redirect "$1")" "$HOST$2" } assert_version_redirect() { - [ "$(version_redirect "$1")" = "$HOST/$2" ] + assert_eq "$(version_redirect "$1")" "$2" } # make sure the crates built successfully -for crate in /rand/0.7.2/rand /rstest/0.12.1/rstest /sysinfo/0.10.0/sysinfo /constellation-rs/0.1.8/constellation; do - assert_status "$crate" 200 +for crate in /rand/0.7.2/rand /rstest/0.4.1/rstest /sysinfo/0.10.0/sysinfo /constellation-rs/0.1.8/constellation; do + echo "$crate" + assert_status "$crate/" 200 done assert_redirect /bat/0.12.1/bat /crate/bat/0.12.1 @@ -77,7 +88,7 @@ assert_status /constellation-rs/0.1.8/src/constellation/lib.rs.html 200 # make sure it shows source code for docs.rs assert_status /crate/constellation-rs/0.1.8/source/ 200 # with or without trailing slashes -assert_status /crate/constellation-rs/0.1.8/source 200 +assert_redirect /crate/constellation-rs/0.1.8/source /crate/constellation-rs/0.1.8/source/ # check 'Go to latest version' keeps the current page assert_version_redirect /rand/0.6.5/rand/trait.Rng.html \ From d755510a38237bb1b3d510c4199c9bb11c1cd504 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sat, 14 Dec 2019 19:08:11 -0500 Subject: [PATCH 13/21] catch web server errors earlier --- test.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/test.sh b/test.sh index 891ecda9b..0d16efe1c 100755 --- a/test.sh +++ b/test.sh @@ -7,10 +7,21 @@ set -euv +HOST=http://localhost:3000 + docker-compose build +# run a dummy command so that the next background command starts up quickly +# and doesn't try to compete with `build` commands +docker-compose run web -- --help || true # this never exits, run it in the background -# TODO: catch errors if `up` failed docker-compose up -d +# ensure that if the web server doesn't start up we catch the error +for i in $(seq 1 5); do + curl -I $HOST && break + # if we've tried 5 times, exit with error + ! [ $i = 5 ] + sleep 5 +done # build a crate and store it in the database if it does not already exist build() { @@ -33,8 +44,6 @@ build rand 0.6.5 build pyo3 0.2.7 build pyo3 0.8.3 -HOST=http://localhost:3000 - # small wrapper around curl to hide extraneous output curl() { command curl -s -o /dev/null "$@" From 46cc9c9e347193c18792fad8618af7685602f28b Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sun, 15 Dec 2019 03:52:06 -0500 Subject: [PATCH 14/21] cache docker directory should speed up builds significantly --- .github/workflows/ci.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ffa5b38dc..4d3c1173f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,6 +36,18 @@ jobs: key: always path: .rustwide-docker + - name: Setup local docker directory + run: > + mkdir -p ignored/docker && + sudo rm -rf /var/lib/docker && + sudo ln -sf "$(realpath ignored/docker)" /var/lib/docker + + - name: Cache docker directory + uses: actions/cache@v1 + with: + key: always + path: ignored/docker + - name: Test docs.rs more thoroughly run: cp .env.sample .env && PATH="$PATH:." ./test.sh From 35294358cff28c4e3933587364746cf165e69956 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sun, 15 Dec 2019 04:04:59 -0500 Subject: [PATCH 15/21] don't remove docker directory from underneath daemon docker doesn't like it when you change its files while it's running --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4d3c1173f..01e8578c5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,8 +39,10 @@ jobs: - name: Setup local docker directory run: > mkdir -p ignored/docker && + sudo systemctl stop docker && sudo rm -rf /var/lib/docker && - sudo ln -sf "$(realpath ignored/docker)" /var/lib/docker + sudo ln -sf "$(realpath ignored/docker)" /var/lib/docker && + sudo systemctl start docker - name: Cache docker directory uses: actions/cache@v1 From 473ea8c43df69463312b2a84a84a6423959402f7 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sun, 15 Dec 2019 04:17:01 -0500 Subject: [PATCH 16/21] make shellcheck happy also uses sh instead of bash since the test file turned out to be portable --- test.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test.sh b/test.sh index 0d16efe1c..c52f1eea0 100755 --- a/test.sh +++ b/test.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/sh # test script for docs.rs # requires the following tools installed: # - docker-compose @@ -19,7 +19,7 @@ docker-compose up -d for i in $(seq 1 5); do curl -I $HOST && break # if we've tried 5 times, exit with error - ! [ $i = 5 ] + ! [ "$i" = 5 ] sleep 5 done @@ -57,13 +57,13 @@ die() { # give the HTTP status of a page hosted locally status() { - curl -I -w %{http_code} "$HOST$1" + curl -I -w "%{http_code}" "$HOST$1" } # give the URL a page hosted locally redirects to # if the page does not redirect, returns the same page it was given redirect() { - curl -IL -w %{url_effective} "$HOST$1" + curl -IL -w "%{url_effective}" "$HOST$1" } version_redirect() { From ffea742ec4168be2130bcb844acd4e9c665c3e61 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sun, 15 Dec 2019 04:19:42 -0500 Subject: [PATCH 17/21] test std library redirects --- test.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test.sh b/test.sh index c52f1eea0..895422ff8 100755 --- a/test.sh +++ b/test.sh @@ -111,5 +111,12 @@ assert_version_redirect /rand/0.6.5/rand/rngs/struct.JitterRng.html \ # for renamed items assert_version_redirect /pyo3/0.2.7/pyo3/exc/struct.ArithmeticError.html \ "/pyo3/0.8.3/pyo3/?search=ArithmeticError" +# check std library redirects +for crate in std alloc core proc_macro test; do + echo $crate + # with or without slash + assert_eq "$(redirect /$crate)" https://doc.rust-lang.org/stable/$crate/ + assert_eq "$(redirect /$crate/)" https://doc.rust-lang.org/stable/$crate/ +done docker-compose down From 53cdacced30a6653297861cb7443531c56f36abb Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sun, 15 Dec 2019 13:17:34 -0500 Subject: [PATCH 18/21] [BROKEN] make docker directory world readable doesn't preserve ownership or write permissions --- .github/workflows/ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 01e8578c5..a38d92386 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,7 +51,11 @@ jobs: path: ignored/docker - name: Test docs.rs more thoroughly - run: cp .env.sample .env && PATH="$PATH:." ./test.sh + run: > + cp .env.sample .env && + PATH="$PATH:." ./test.sh && + find ignored/docker -type d -exec sudo chmod a+rx {} \; && + find ignored/docker -type f -exec sudo chmod a+r {} \; # hack so that caching works docker: name: Docker From 7c1a2ac19b74bc4f5607019ee32874bc0d962068 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Mon, 16 Dec 2019 08:30:24 -0500 Subject: [PATCH 19/21] remove cache this went way over github's limits and was failing the build. --- .github/workflows/ci.yml | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a38d92386..f4006237f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,32 +30,10 @@ jobs: ec3d29e9fb375b87ac492c8b546ad6be84b0c0b49dab7ff4c6b582eac71ba01c ] && unzip pup_v0.4.0_linux_amd64.zip - - name: Cache Rustwide directory - uses: actions/cache@v1 - with: - key: always - path: .rustwide-docker - - - name: Setup local docker directory - run: > - mkdir -p ignored/docker && - sudo systemctl stop docker && - sudo rm -rf /var/lib/docker && - sudo ln -sf "$(realpath ignored/docker)" /var/lib/docker && - sudo systemctl start docker - - - name: Cache docker directory - uses: actions/cache@v1 - with: - key: always - path: ignored/docker - - name: Test docs.rs more thoroughly run: > cp .env.sample .env && PATH="$PATH:." ./test.sh && - find ignored/docker -type d -exec sudo chmod a+rx {} \; && - find ignored/docker -type f -exec sudo chmod a+r {} \; # hack so that caching works docker: name: Docker From ad1cdfa935748537d4fe79ddcdeab1d5e9870262 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Wed, 18 Dec 2019 21:20:45 -0500 Subject: [PATCH 20/21] Fix syntax error --- .github/workflows/ci.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f4006237f..32066f538 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,9 +31,7 @@ jobs: unzip pup_v0.4.0_linux_amd64.zip - name: Test docs.rs more thoroughly - run: > - cp .env.sample .env && - PATH="$PATH:." ./test.sh && + run: cp .env.sample .env && PATH="$PATH:." ./test.sh docker: name: Docker From 922f54a80bdfba9c08a8aae338a02c9abad70712 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Fri, 20 Dec 2019 21:32:32 -0500 Subject: [PATCH 21/21] use fast_init for CI --- src/docbuilder/rustwide_builder.rs | 4 ++++ test.sh | 12 ++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/docbuilder/rustwide_builder.rs b/src/docbuilder/rustwide_builder.rs index 61a1099d7..ed1f3e1d3 100644 --- a/src/docbuilder/rustwide_builder.rs +++ b/src/docbuilder/rustwide_builder.rs @@ -73,8 +73,12 @@ impl RustwideBuilder { let is_docker = std::env::var("DOCS_RS_DOCKER") .map(|s| s == "true") .unwrap_or(false); + let fast_init = std::env::var("DOCS_RS_FAST_INIT") + .map(|s| s == "true") + .unwrap_or(false); let workspace = WorkspaceBuilder::new(Path::new(workspace_path), USER_AGENT) .running_inside_docker(is_docker) + .fast_init(fast_init) .init()?; workspace.purge_all_build_dirs()?; diff --git a/test.sh b/test.sh index 895422ff8..f646fd862 100755 --- a/test.sh +++ b/test.sh @@ -9,6 +9,16 @@ set -euv HOST=http://localhost:3000 +cp .env .env.bak + +cleanup() { + mv .env.bak .env + docker-compose down +} + +trap cleanup exit +echo DOCS_RS_FAST_INIT=true >> .env + docker-compose build # run a dummy command so that the next background command starts up quickly # and doesn't try to compete with `build` commands @@ -118,5 +128,3 @@ for crate in std alloc core proc_macro test; do assert_eq "$(redirect /$crate)" https://doc.rust-lang.org/stable/$crate/ assert_eq "$(redirect /$crate/)" https://doc.rust-lang.org/stable/$crate/ done - -docker-compose down