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

Run crates.io inside Travis (without Docker) #1825

Closed
wants to merge 1 commit 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 12 additions & 1 deletion .travis.yml
Expand Up @@ -20,12 +20,13 @@ env:
- PERCY_TOKEN=0d8707a02b19aebbec79bb0bf302b8d2fa95edb33169cfe41b084289596670b1
- PERCY_PROJECT=crates-io/crates.io
- PGPORT=5433
- PATH=$HOME/.cargo/bin:$PATH

install:
- sudo cp /etc/postgresql/10/main/pg_hba.conf /etc/postgresql/11/main/pg_hba.conf
- sudo systemctl restart postgresql@11-main
- script/ci/cargo-clean-on-new-rustc-version.sh
- cargo install --force diesel_cli --vers `cat .diesel_version` --no-default-features --features postgres && export PATH=$HOME/.cargo/bin:$PATH
- cargo install --force diesel_cli --vers `cat .diesel_version` --no-default-features --features postgres

before_script:
- diesel database setup --locked-schema
Expand Down Expand Up @@ -63,6 +64,16 @@ matrix:
- npm run lint:js
- npm run lint:deps
- npm test
- name: Integration Tests
language: node_js
Copy link
Member

Choose a reason for hiding this comment

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

Even though we have cache.cargo: true above, it looks like this job isn't actually caching any of our Rust build artifacts. I recently realized that travis seems to use different VM images depending on the selected language type. It seems like other behavior, like caching here, must also be dependent on the language type.

This brings me to a general thought. We previously run the frontend tests within our rust: stable job. It seems like it might be cleaner to combine these back into a single job and run any integration tests there as well. That would reduce the duplication of running the split jobs and duplicating the build work from both of those in this integration job. The downside is that I'm starting to see that Travis doesn't really seem to be set up to gracefully handle multiple languages/frameworks within the same job.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I personally prefer the separation. We tend to have either JavaScript-only or Rust-only PRs. The separation helps developers understand what's not working - and which test failures are false-positives.

Between stages, Travis doesn't share any files. Can't we have a S3 bucket to keep intermediate artifacts?

https://docs.travis-ci.com/user/build-stages/#data-persistence-between-stages-and-jobs

Copy link
Member

Choose a reason for hiding this comment

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

I don't have access to create an S3 bucket for intermediate artifacts, but I've added it to the agenda at rust-lang/crates-io-cargo-teams#60 to discuss at the next team meeting.

node_js: 12
before_install:
# Install Rust, since Travis prepares Node.js box for this job
- curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
script:
- npm ci
- cargo build
- ./script/ci/start-frontend-and-backend.sh
- rust: beta
script:
- cargo test
Expand Down
42 changes: 42 additions & 0 deletions script/ci/start-frontend-and-backend.sh
@@ -0,0 +1,42 @@
#! /bin/bash
set -euo pipefail

./script/init-local-index.sh

# The below are required environment variables
export SESSION_KEY=badkeyabcdefghijklmnopqrstuvwxyzabcdef
export GIT_REPO_CHECKOUT=./tmp/index-co
export GIT_REPO_URL=file://./tmp/index-bare
export GH_CLIENT_ID=
export GH_CLIENT_SECRET=

./target/debug/server > backend.log &
npm run start -- --proxy http://localhost:8888 > frontend.log &

for i in $(seq 1 10)
do
set +e
curl -H 'Accept: text/html' http://localhost:4200
case $? in
0)
break
;;
7)
# Connection refused
sleep 10
;;
56)
# Connection reset by peer
sleep 10
;;
*)
exit $?
esac
set -e
done

echo FRONTEND
cat frontend.log

echo BACKEND
cat backend.log