@@ -49,32 +49,39 @@ jobs:
49
49
restore-key : |
50
50
${{ runner.os }}-cargo-build-target-${{ env.CURRENT_RUSTC_VERSION }}-
51
51
52
- - name : Install PostgreSQL
52
+ - name : Prepare the test environment
53
53
run : |
54
- sudo apt-get update && DEBIAN_FRONTEND=noninteractive sudo apt-get install -y postgresql
55
- sudo systemctl start postgresql
56
- sudo -u postgres createuser $(whoami) -w
57
- sudo -u postgres createdb $(whoami) -O $(whoami)
58
- echo "::set-env name=CRATESFYI_DATABASE_URL::postgresql://$(whoami)@%2Fvar%2Frun%2Fpostgresql/$(whoami)"
54
+ prefix=$(pwd)/ignored/prefix
55
+ mkdir -p ${prefix}/public-html
56
+ echo "::set-env name=CRATESFYI_PREFIX::${prefix}"
59
57
60
- - name : Build docs.rs
61
- run : cargo build --locked
58
+ - name : Launch the postgres image
59
+ run : |
60
+ touch .env
61
+ docker-compose up -d db
62
+ # TODO: try to avoid hard-coding this username/password
63
+ export CRATESFYI_DATABASE_URL="postgresql://cratesfyi:password@localhost:5432/"
64
+ # Make sure the database is actually working
65
+ # Give the database enough time to start up
66
+ sleep 5
67
+ psql "$CRATESFYI_DATABASE_URL"
68
+ echo "::set-env name=CRATESFYI_DATABASE_URL::${CRATESFYI_DATABASE_URL}"
62
69
63
70
- name : Run rustfmt
64
71
run : cargo fmt -- --check
65
72
66
73
- name : Run clippy
67
- run : cargo clippy -- -D warnings
74
+ run : cargo clippy --locked -- -D warnings
68
75
69
- - name : Prepare the test environment
70
- run : |
71
- prefix=$(pwd)/ignored/prefix
72
- mkdir -p ${prefix}/public-html
73
- echo "::set-env name=CRATESFYI_PREFIX::${prefix}"
76
+ - name : Build docs.rs
77
+ run : cargo build --locked
74
78
75
79
- name : Test docs.rs
76
80
run : cargo test --locked -- --test-threads=1
77
81
82
+ - name : Clean up the database
83
+ run : docker-compose down --volumes
84
+
78
85
docker :
79
86
name : Docker
80
87
runs-on : ubuntu-latest
0 commit comments