From 78e4b71efc7492de2ab3f42f1380599e5d3f230e Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 16 Mar 2022 18:04:34 +0100 Subject: [PATCH 1/7] Add GUI tests --- .github/workflows/ci.yml | 3 + README.md | 9 ++ docker-compose.yml | 10 ++ dockerfiles/Dockerfile-gui-tests | 87 +++++++++++ dockerfiles/run-gui-tests.sh | 36 +++++ gui-tests/404.goml | 3 + gui-tests/basic.goml | 12 ++ gui-tests/tester.js | 252 +++++++++++++++++++++++++++++++ 8 files changed, 412 insertions(+) create mode 100644 dockerfiles/Dockerfile-gui-tests create mode 100755 dockerfiles/run-gui-tests.sh create mode 100644 gui-tests/404.goml create mode 100644 gui-tests/basic.goml create mode 100644 gui-tests/tester.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6ac947ca6..6ab2b9ac1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -127,6 +127,9 @@ jobs: $f || exit 1 done + - name: Run GUI tests + run: ./dockerfiles/run-gui-tests.sh + - name: Clean up the database run: docker-compose down --volumes diff --git a/README.md b/README.md index b16834f40..d50777109 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,15 @@ Note that you will need docker installed no matter what, since it's used for Rus cargo test ``` +To run GUI tests: + +``` +./dockerfiles/run-gui-tests.sh +``` + +They use the [browser-ui-test](https://github.com/GuillaumeGomez/browser-UI-test/) framework. You +can take a look at its documentation [here](https://github.com/GuillaumeGomez/browser-UI-test/blob/master/goml-script.md). + ### Pure docker-compose If you have trouble with the above commands, consider using `docker-compose up --build`, diff --git a/docker-compose.yml b/docker-compose.yml index 36180aa3d..ce503de9c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -90,6 +90,16 @@ services: timeout: 5s retries: 10 + gui_tests: + build: + context: . + dockerfile: ./dockerfiles/Dockerfile-gui-tests + network_mode: "host" + extra_hosts: + - "host.docker.internal:host-gateway" + volumes: + - "${PWD}:/build/out" + volumes: postgres-data: {} minio-data: {} diff --git a/dockerfiles/Dockerfile-gui-tests b/dockerfiles/Dockerfile-gui-tests new file mode 100644 index 000000000..c9ba54419 --- /dev/null +++ b/dockerfiles/Dockerfile-gui-tests @@ -0,0 +1,87 @@ +FROM ubuntu:22.04 AS build + +# Install packaged dependencies +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + build-essential git curl cmake gcc g++ pkg-config libmagic-dev \ + libssl-dev zlib1g-dev ca-certificates + +# Install the stable toolchain with rustup +RUN curl https://sh.rustup.rs >/tmp/rustup-init && \ + chmod +x /tmp/rustup-init && \ + /tmp/rustup-init -y --no-modify-path --default-toolchain stable --profile minimal +ENV PATH=/root/.cargo/bin:$PATH + +RUN apt-get update && apt-get install -y \ + ca-certificates \ + curl \ + docker.io \ + gcc \ + git \ + libssl-dev \ + pkg-config \ + xz-utils + +# Install dependencies for chromium browser +RUN apt-get install -y \ + gconf-service \ + libasound2 \ + libatk1.0-0 \ + libatk-bridge2.0-0 \ + libc6 \ + libcairo2 \ + libcups2 \ + libdbus-1-3 \ + libexpat1 \ + libfontconfig1 \ + libgbm-dev \ + libgcc1 \ + libgconf-2-4 \ + libgdk-pixbuf2.0-0 \ + libglib2.0-0 \ + libgtk-3-0 \ + libnspr4 \ + libpango-1.0-0 \ + libpangocairo-1.0-0 \ + libstdc++6 \ + libx11-6 \ + libx11-xcb1 \ + libxcb1 \ + libxcomposite1 \ + libxcursor1 \ + libxdamage1 \ + libxext6 \ + libxfixes3 \ + libxi6 \ + libxrandr2 \ + libxrender1 \ + libxss1 \ + libxtst6 \ + fonts-liberation \ + libappindicator1 \ + libnss3 \ + lsb-release \ + xdg-utils \ + wget + +# Install rust +RUN curl https://sh.rustup.rs -sSf | bash -s -- -y --default-toolchain nightly --no-modify-path --profile minimal +ENV PATH="/root/.cargo/bin:${PATH}" + +RUN curl -sL https://nodejs.org/dist/v14.4.0/node-v14.4.0-linux-x64.tar.xz | tar -xJ +ENV PATH="/node-v14.4.0-linux-x64/bin:${PATH}" +ENV NODE_PATH="/node-v14.4.0-linux-x64/lib/node_modules/" + +WORKDIR /build + +RUN mkdir out + +# For now, we need to use `--unsafe-perm=true` to go around an issue when npm tries +# to create a new folder. For reference: +# https://github.com/puppeteer/puppeteer/issues/375 +# +# We also specify the version in case we need to update it to go around cache limitations. +RUN npm install -g browser-ui-test@0.8.5 --unsafe-perm=true + +EXPOSE 3000 + +CMD ["node", "/build/out/gui-tests/tester.js"] diff --git a/dockerfiles/run-gui-tests.sh b/dockerfiles/run-gui-tests.sh new file mode 100755 index 000000000..8036e8f90 --- /dev/null +++ b/dockerfiles/run-gui-tests.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +# Just in case it's running, we stop the web server. +docker-compose stop web + +docker-compose up -d db s3 + +# We add the information we need. +cargo run -- database migrate +docker-compose run web build crate sysinfo 0.23.4 +docker-compose run web build crate sysinfo 0.23.5 +docker-compose run web build add-essential-files +docker-compose build web + +# In case we don't have a `.env`, we create one. +if [ ! -f .env ] +then +cp .env.sample .env +source .env +fi + +docker-compose up -d web + +cargo run -- start-web-server & +SERVER_PID=$! + +docker build . -f dockerfiles/Dockerfile-gui-tests -t gui_tests + +echo "Sleeping a bit to be sure the web server will be started..." +sleep 5 + +# status="docker run . -v `pwd`:/build/out:ro gui_tests" +docker-compose run gui_tests +status=$? +kill -9 $SERVER_PID +exit $status diff --git a/gui-tests/404.goml b/gui-tests/404.goml new file mode 100644 index 000000000..d71da15a5 --- /dev/null +++ b/gui-tests/404.goml @@ -0,0 +1,3 @@ +// Checks the content of the 404 page. +goto: |DOC_PATH|/non-existing-crate +assert-text: ("#crate-title", "The requested crate does not exist") diff --git a/gui-tests/basic.goml b/gui-tests/basic.goml new file mode 100644 index 000000000..787df11f8 --- /dev/null +++ b/gui-tests/basic.goml @@ -0,0 +1,12 @@ +// Checks that the "latest" URL leads us to the last version of the `sysinfo` crate. +goto: |DOC_PATH|/sysinfo +// We first check if the redirection worked as expected: +assert-document-property: ({"URL": "/sysinfo/latest/sysinfo/"}, ENDS_WITH) +assert: "//*[@class='title' and text()='sysinfo-0.23.5']" +// And we also confirm we're on a rustdoc page. +assert: "#rustdoc_body_wrapper" + +// Let's go to the docs.rs page of the crate. +goto: |DOC_PATH|/crate/sysinfo/latest +assert-false: "#rustdoc_body_wrapper" +assert-text: ("#crate-title", "sysinfo 0.23.5", CONTAINS) diff --git a/gui-tests/tester.js b/gui-tests/tester.js new file mode 100644 index 000000000..34bd77d7c --- /dev/null +++ b/gui-tests/tester.js @@ -0,0 +1,252 @@ +// This package needs to be install: +// +// ``` +// npm install browser-ui-test +// ``` + +const fs = require("fs"); +const path = require("path"); +const os = require('os'); +const {Options, runTest} = require('browser-ui-test'); + +function showHelp() { + console.log("docs-rs-gui-js options:"); + console.log(" --file [PATH] : file to run (can be repeated)"); + console.log(" --debug : show extra information about script run"); + console.log(" --show-text : render font in pages"); + console.log(" --no-headless : disable headless mode"); + console.log(" --help : show this message then quit"); + console.log(" --jobs [NUMBER] : number of threads to run tests on"); +} + +function isNumeric(s) { + return /^\d+$/.test(s); +} + +function parseOptions(args) { + var opts = { + "files": [], + "debug": false, + "show_text": false, + "no_headless": false, + "jobs": -1, + }; + var correspondances = { + "--debug": "debug", + "--show-text": "show_text", + "--no-headless": "no_headless", + }; + + for (var i = 0; i < args.length; ++i) { + if (args[i] === "--file" + || args[i] === "--jobs") { + i += 1; + if (i >= args.length) { + console.log("Missing argument after `" + args[i - 1] + "` option."); + return null; + } + if (args[i - 1] === "--jobs") { + if (!isNumeric(args[i])) { + console.log( + "`--jobs` option expects a positive number, found `" + args[i] + "`"); + return null; + } + opts["jobs"] = parseInt(args[i]); + } else if (args[i - 1] !== "--file") { + opts[correspondances[args[i - 1]]] = args[i]; + } else { + opts["files"].push(args[i]); + } + } else if (args[i] === "--help") { + showHelp(); + process.exit(0); + } else if (correspondances[args[i]]) { + opts[correspondances[args[i]]] = true; + } else { + console.log("Unknown option `" + args[i] + "`."); + console.log("Use `--help` to see the list of options"); + return null; + } + } + return opts; +} + +/// Print single char status information without \n +function char_printer(n_tests) { + const max_per_line = 10; + let current = 0; + return { + successful: function() { + current += 1; + if (current % max_per_line === 0) { + process.stdout.write(`. (${current}/${n_tests})${os.EOL}`); + } else { + process.stdout.write("."); + } + }, + erroneous: function() { + current += 1; + if (current % max_per_line === 0) { + process.stderr.write(`F (${current}/${n_tests})${os.EOL}`); + } else { + process.stderr.write("F"); + } + }, + finish: function() { + if (current % max_per_line === 0) { + // Don't output if we are already at a matching line end + console.log(""); + } else { + const spaces = " ".repeat(max_per_line - (current % max_per_line)); + process.stdout.write(`${spaces} (${current}/${n_tests})${os.EOL}${os.EOL}`); + } + }, + }; +} + +/// Sort array by .file_name property +function by_filename(a, b) { + return a.file_name - b.file_name; +} + +async function main(argv) { + let opts = parseOptions(argv.slice(2)); + if (opts === null) { + process.exit(1); + } + + // Print successful tests too + let debug = false; + // Run tests in sequentially + let headless = true; + const options = new Options(); + try { + // This is more convenient that setting fields one by one. + let args = [ + "--no-screenshot-comparison", + "--no-sandbox", + ]; + if (typeof process.env.SERVER_URL !== 'undefined') { + args.push("--variable", "DOC_PATH", process.env.SERVER_URL); + } else { + args.push("--variable", "DOC_PATH", "http://127.0.0.1:3000"); + } + if (opts["debug"]) { + debug = true; + args.push("--debug"); + } + if (opts["show_text"]) { + args.push("--show-text"); + } + if (opts["no_headless"]) { + args.push("--no-headless"); + headless = false; + } + options.parseArguments(args); + } catch (error) { + console.error(`invalid argument: ${error}`); + process.exit(1); + } + + let failed = false; + let files; + if (opts["files"].length === 0) { + files = fs.readdirSync(__dirname); + } else { + files = opts["files"]; + } + files = files.filter(file => path.extname(file) == ".goml"); + if (files.length === 0) { + console.error("No test selected"); + process.exit(2); + } + files.sort(); + + if (!headless) { + opts["jobs"] = 1; + console.log("`--no-headless` option is active, disabling concurrency for running tests."); + } + + console.log(`Running ${files.length} docs.rs GUI (${opts["jobs"]} concurrently) ...`); + + if (opts["jobs"] < 1) { + process.setMaxListeners(files.length + 1); + } else if (headless) { + process.setMaxListeners(opts["jobs"] + 1); + } + + const tests_queue = []; + let results = { + successful: [], + failed: [], + errored: [], + }; + const status_bar = char_printer(files.length); + for (let i = 0; i < files.length; ++i) { + const file_name = files[i]; + const testPath = path.join(__dirname, file_name); + const callback = runTest(testPath, options) + .then(out => { + const [output, nb_failures] = out; + results[nb_failures === 0 ? "successful" : "failed"].push({ + file_name: testPath, + output: output, + }); + if (nb_failures > 0) { + status_bar.erroneous(); + failed = true; + } else { + status_bar.successful(); + } + }) + .catch(err => { + results.errored.push({ + file_name: testPath + file_name, + output: err, + }); + status_bar.erroneous(); + failed = true; + }) + .finally(() => { + // We now remove the promise from the tests_queue. + tests_queue.splice(tests_queue.indexOf(callback), 1); + }); + tests_queue.push(callback); + if (opts["jobs"] > 0 && tests_queue.length >= opts["jobs"]) { + await Promise.race(tests_queue); + } + } + if (tests_queue.length > 0) { + await Promise.all(tests_queue); + } + status_bar.finish(); + + if (debug) { + results.successful.sort(by_filename); + results.successful.forEach(r => { + console.log(r.output); + }); + } + + if (results.failed.length > 0) { + console.log(""); + results.failed.sort(by_filename); + results.failed.forEach(r => { + console.log(r.file_name, r.output); + }); + } + if (results.errored.length > 0) { + console.log(os.EOL); + // print run errors on the bottom so developers see them better + results.errored.sort(by_filename); + results.errored.forEach(r => { + console.error(r.file_name, r.output); + }); + } + + if (failed) { + process.exit(1); + } +} + +main(process.argv); From 57f0a8398aca4746762c243a465f0db0adff4928 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 16 Oct 2023 18:19:56 +0200 Subject: [PATCH 2/7] Update to newest browser-ui-test version --- dockerfiles/Dockerfile-gui-tests | 4 ++-- dockerfiles/run-gui-tests.sh | 3 +-- gui-tests/404.goml | 2 +- gui-tests/basic.goml | 6 ++++-- gui-tests/tester.js | 8 ++++---- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/dockerfiles/Dockerfile-gui-tests b/dockerfiles/Dockerfile-gui-tests index c9ba54419..d16553ec0 100644 --- a/dockerfiles/Dockerfile-gui-tests +++ b/dockerfiles/Dockerfile-gui-tests @@ -64,7 +64,7 @@ RUN apt-get install -y \ wget # Install rust -RUN curl https://sh.rustup.rs -sSf | bash -s -- -y --default-toolchain nightly --no-modify-path --profile minimal +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y --default-toolchain nightly --no-modify-path --profile minimal ENV PATH="/root/.cargo/bin:${PATH}" RUN curl -sL https://nodejs.org/dist/v14.4.0/node-v14.4.0-linux-x64.tar.xz | tar -xJ @@ -80,7 +80,7 @@ RUN mkdir out # https://github.com/puppeteer/puppeteer/issues/375 # # We also specify the version in case we need to update it to go around cache limitations. -RUN npm install -g browser-ui-test@0.8.5 --unsafe-perm=true +RUN npm install -g browser-ui-test@0.16.10 --unsafe-perm=true EXPOSE 3000 diff --git a/dockerfiles/run-gui-tests.sh b/dockerfiles/run-gui-tests.sh index 8036e8f90..fdecfee29 100755 --- a/dockerfiles/run-gui-tests.sh +++ b/dockerfiles/run-gui-tests.sh @@ -16,7 +16,7 @@ docker-compose build web if [ ! -f .env ] then cp .env.sample .env -source .env +. .env fi docker-compose up -d web @@ -32,5 +32,4 @@ sleep 5 # status="docker run . -v `pwd`:/build/out:ro gui_tests" docker-compose run gui_tests status=$? -kill -9 $SERVER_PID exit $status diff --git a/gui-tests/404.goml b/gui-tests/404.goml index d71da15a5..546e09a80 100644 --- a/gui-tests/404.goml +++ b/gui-tests/404.goml @@ -1,3 +1,3 @@ // Checks the content of the 404 page. -goto: |DOC_PATH|/non-existing-crate +go-to: |DOC_PATH| + "/non-existing-crate" assert-text: ("#crate-title", "The requested crate does not exist") diff --git a/gui-tests/basic.goml b/gui-tests/basic.goml index 787df11f8..3e50211bf 100644 --- a/gui-tests/basic.goml +++ b/gui-tests/basic.goml @@ -1,12 +1,14 @@ // Checks that the "latest" URL leads us to the last version of the `sysinfo` crate. -goto: |DOC_PATH|/sysinfo +go-to: |DOC_PATH| + "/sysinfo" // We first check if the redirection worked as expected: assert-document-property: ({"URL": "/sysinfo/latest/sysinfo/"}, ENDS_WITH) +// Now we go to the actual version we're interested into. +go-to: |DOC_PATH| + "/sysinfo/0.23.5/sysinfo/index.html" assert: "//*[@class='title' and text()='sysinfo-0.23.5']" // And we also confirm we're on a rustdoc page. assert: "#rustdoc_body_wrapper" // Let's go to the docs.rs page of the crate. -goto: |DOC_PATH|/crate/sysinfo/latest +go-to: |DOC_PATH| + "/crate/sysinfo/0.23.5" assert-false: "#rustdoc_body_wrapper" assert-text: ("#crate-title", "sysinfo 0.23.5", CONTAINS) diff --git a/gui-tests/tester.js b/gui-tests/tester.js index 34bd77d7c..ff3c9b7e9 100644 --- a/gui-tests/tester.js +++ b/gui-tests/tester.js @@ -123,7 +123,6 @@ async function main(argv) { try { // This is more convenient that setting fields one by one. let args = [ - "--no-screenshot-comparison", "--no-sandbox", ]; if (typeof process.env.SERVER_URL !== 'undefined') { @@ -166,14 +165,15 @@ async function main(argv) { opts["jobs"] = 1; console.log("`--no-headless` option is active, disabling concurrency for running tests."); } - - console.log(`Running ${files.length} docs.rs GUI (${opts["jobs"]} concurrently) ...`); + let jobs = opts["jobs"]; if (opts["jobs"] < 1) { + jobs = files.length; process.setMaxListeners(files.length + 1); } else if (headless) { process.setMaxListeners(opts["jobs"] + 1); } + console.log(`Running ${files.length} docs.rs GUI (${jobs} concurrently) ...`); const tests_queue = []; let results = { @@ -185,7 +185,7 @@ async function main(argv) { for (let i = 0; i < files.length; ++i) { const file_name = files[i]; const testPath = path.join(__dirname, file_name); - const callback = runTest(testPath, options) + const callback = runTest(testPath, {"options": options}) .then(out => { const [output, nb_failures] = out; results[nb_failures === 0 ? "successful" : "failed"].push({ From 32539dd0f05034c2453aed1b901d875ac1b4e2ed Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 20 Oct 2023 11:31:26 +0200 Subject: [PATCH 3/7] Move GUI tests into their own --- .github/workflows/ci.yml | 25 +++++++++++++++++++++++++ dockerfiles/run-gui-tests.sh | 12 +++--------- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6ab2b9ac1..276263138 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -127,6 +127,31 @@ jobs: $f || exit 1 done + - name: Clean up the database + run: docker-compose down --volumes + + GUIs_test: + runs-on: ubuntu-latest + needs: build + steps: + - uses: actions/checkout@v4 + + - name: get test binaries from cache + uses: actions/download-artifact@v3 + with: + name: test-binaries-${{ github.sha }} + path: ./test-binaries/ + + - name: Launch postgres and min.io + run: | + cp .env.sample .env + mkdir -p ${DOCSRS_PREFIX}/public-html + docker-compose up -d db s3 + # Give the database enough time to start up + sleep 5 + # Make sure the database is actually working + psql "${DOCSRS_DATABASE_URL}" + - name: Run GUI tests run: ./dockerfiles/run-gui-tests.sh diff --git a/dockerfiles/run-gui-tests.sh b/dockerfiles/run-gui-tests.sh index fdecfee29..ee10c136a 100755 --- a/dockerfiles/run-gui-tests.sh +++ b/dockerfiles/run-gui-tests.sh @@ -7,10 +7,9 @@ docker-compose up -d db s3 # We add the information we need. cargo run -- database migrate -docker-compose run web build crate sysinfo 0.23.4 -docker-compose run web build crate sysinfo 0.23.5 -docker-compose run web build add-essential-files -docker-compose build web +cargo run -- build crate sysinfo 0.23.4 +cargo run -- build crate sysinfo 0.23.5 +cargo run -- build add-essential-files # In case we don't have a `.env`, we create one. if [ ! -f .env ] @@ -19,16 +18,11 @@ cp .env.sample .env . .env fi -docker-compose up -d web - cargo run -- start-web-server & SERVER_PID=$! docker build . -f dockerfiles/Dockerfile-gui-tests -t gui_tests -echo "Sleeping a bit to be sure the web server will be started..." -sleep 5 - # status="docker run . -v `pwd`:/build/out:ro gui_tests" docker-compose run gui_tests status=$? From 3bbec56c0b0c41b02b41095c2a98d0f9d1a4373d Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 3 Nov 2023 15:09:01 +0100 Subject: [PATCH 4/7] Fix missing environment setup --- .github/workflows/ci.yml | 2 +- dockerfiles/run-gui-tests.sh | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 276263138..b32a9797a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -130,7 +130,7 @@ jobs: - name: Clean up the database run: docker-compose down --volumes - GUIs_test: + GUI_test: runs-on: ubuntu-latest needs: build steps: diff --git a/dockerfiles/run-gui-tests.sh b/dockerfiles/run-gui-tests.sh index ee10c136a..93244b28c 100755 --- a/dockerfiles/run-gui-tests.sh +++ b/dockerfiles/run-gui-tests.sh @@ -12,12 +12,11 @@ cargo run -- build crate sysinfo 0.23.5 cargo run -- build add-essential-files # In case we don't have a `.env`, we create one. -if [ ! -f .env ] -then +if [ ! -f .env ]; then cp .env.sample .env -. .env fi +. .env cargo run -- start-web-server & SERVER_PID=$! From caf422e5d2e7ac6863c8ac8e8be68dd3dcb1ec80 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 3 Nov 2023 15:11:35 +0100 Subject: [PATCH 5/7] Stop bash script at first error --- dockerfiles/run-gui-tests.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dockerfiles/run-gui-tests.sh b/dockerfiles/run-gui-tests.sh index 93244b28c..f1415fb54 100755 --- a/dockerfiles/run-gui-tests.sh +++ b/dockerfiles/run-gui-tests.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +set -e + # Just in case it's running, we stop the web server. docker-compose stop web From dfb87e41495d8f34e1172d4e8841632a7ff1e990 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 3 Nov 2023 16:10:42 +0100 Subject: [PATCH 6/7] Fix CI compilation error --- .github/workflows/ci.yml | 11 ++++++----- dockerfiles/Dockerfile-gui-tests | 6 ------ dockerfiles/run-gui-tests.sh | 14 +++++++++++++- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b32a9797a..d94f3c27a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -135,12 +135,13 @@ jobs: needs: build steps: - uses: actions/checkout@v4 + - id: install + run: | + rustup override set stable + rustup update stable - - name: get test binaries from cache - uses: actions/download-artifact@v3 - with: - name: test-binaries-${{ github.sha }} - path: ./test-binaries/ + - name: restore build & cargo cache + uses: Swatinem/rust-cache@v2 - name: Launch postgres and min.io run: | diff --git a/dockerfiles/Dockerfile-gui-tests b/dockerfiles/Dockerfile-gui-tests index d16553ec0..4e4108d2d 100644 --- a/dockerfiles/Dockerfile-gui-tests +++ b/dockerfiles/Dockerfile-gui-tests @@ -5,12 +5,6 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins build-essential git curl cmake gcc g++ pkg-config libmagic-dev \ libssl-dev zlib1g-dev ca-certificates -# Install the stable toolchain with rustup -RUN curl https://sh.rustup.rs >/tmp/rustup-init && \ - chmod +x /tmp/rustup-init && \ - /tmp/rustup-init -y --no-modify-path --default-toolchain stable --profile minimal -ENV PATH=/root/.cargo/bin:$PATH - RUN apt-get update && apt-get install -y \ ca-certificates \ curl \ diff --git a/dockerfiles/run-gui-tests.sh b/dockerfiles/run-gui-tests.sh index f1415fb54..6fb49bb36 100755 --- a/dockerfiles/run-gui-tests.sh +++ b/dockerfiles/run-gui-tests.sh @@ -7,18 +7,30 @@ docker-compose stop web docker-compose up -d db s3 +# If we have a .env file, we need to temporarily move it so +# it doesn't make sqlx fail compilation. +if [ -f .env ]; then + mv .env .tmp.env +fi + # We add the information we need. cargo run -- database migrate +cargo run -- build update-toolchain cargo run -- build crate sysinfo 0.23.4 cargo run -- build crate sysinfo 0.23.5 cargo run -- build add-essential-files +if [ -f .tmp.env ]; then + mv .tmp.env .env +fi + # In case we don't have a `.env`, we create one. if [ ! -f .env ]; then -cp .env.sample .env + cp .env.sample .env fi . .env + cargo run -- start-web-server & SERVER_PID=$! From fb26bf816634171e31bfcee943f366e3a45f743d Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 15 Nov 2023 11:22:58 +0100 Subject: [PATCH 7/7] Remove `docker build` command --- dockerfiles/run-gui-tests.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/dockerfiles/run-gui-tests.sh b/dockerfiles/run-gui-tests.sh index 6fb49bb36..ea9fa4e06 100755 --- a/dockerfiles/run-gui-tests.sh +++ b/dockerfiles/run-gui-tests.sh @@ -34,8 +34,6 @@ fi cargo run -- start-web-server & SERVER_PID=$! -docker build . -f dockerfiles/Dockerfile-gui-tests -t gui_tests - # status="docker run . -v `pwd`:/build/out:ro gui_tests" docker-compose run gui_tests status=$?