@@ -67,84 +67,112 @@ yarn run ember test --server
67
67
68
68
## Working on the Backend
69
69
70
- After cloning the repo, steps for setting up the backend API server are as
71
- follows:
70
+ Working on the backend requires a usable postgres server and to configure
71
+ crates.io to use it. There are slight differences in configuration for
72
+ hosting the backend and running tests, both of which are described in more
73
+ details in the appropriate subsections.
72
74
73
- 1 . Install [ Postgres] ( https://www.postgresql.org/ ) >= 9.5 and create a
74
- database. For example, if you wanted your database to be named
75
- ` cargo_registry ` , you can run ` psql ` to connect to postgres, then run
76
- ` CREATE DATABASE cargo_registry; ` .
75
+ After cloning the repo, do the following:
77
76
78
- 2 . Copy the ` .env.sample ` file to ` .env ` and change any applicable values as
79
- directed by the comments in the file. Make sure the values in your new
80
- ` .env ` are exported in the shell you use for the following commands.
77
+ 1 . Install [ Postgres] ( https://www.postgresql.org/ ) >= 9.5. On Linux this is
78
+ generally available in the distribution repositories as ` postgresql ` or
79
+ ` postgresql-server ` . This will need to be up and running for running tests
80
+ for hosting the site locally.
81
81
82
- 3 . Set up the git index:
82
+ 2 . Copy the ` .env.sample ` file to ` .env ` . Some settings will need to be
83
+ modified. These instructions are in the subsequent sections.
83
84
84
- ```
85
- ./script/init-local-index.sh
86
- ```
85
+ ### Running Tests
87
86
88
- But *do not* modify your `~/.cargo/config` yet. Do that after step 3.
87
+ After following the above instructions:
89
88
90
- 4. Build the server:
89
+ 1 . Configure the location of the test database. Create a database specifically
90
+ for testing since running the tests will clear the database. For example,
91
+ to use a database named ` cargo_registry_test ` , create it in postgres by
92
+ running ` psql ` to connect to postgres, then run `CREATE DATABASE
93
+ cargo_registry_test;`. The test harness will ensure that migrations are run.
91
94
92
- ```
93
- cargo build
94
- ```
95
+ In your ` .env ` file, specify your test database URL. Here's an example,
96
+ assuming your test database is named ` cargo_registry_test ` :
95
97
96
- On OS X 10.11, you will need to install the openssl headers first, and tell
97
- cargo where to find them. See https://github.com/sfackler/rust-openssl#osx.
98
+ ```
99
+ export TEST_DATABASE_URL=postgres://postgres@localhost/cargo_registry_test
100
+ ```
98
101
99
- 5. Run the migrations:
102
+ 2 . In your ` .env ` file, set the s3 bucket to ` alexcrichton-test ` . No actual
103
+ requests to s3 will be made; the requests and responses are recorded in
104
+ files in ` tests/http-data ` and the s3 bucket name needs to match the
105
+ requests in the files.
100
106
101
- ```
102
- ./target/debug/migrate
103
- ```
107
+ ```
108
+ export S3_BUCKET=alexcrichton-test
109
+ ```
104
110
105
- 6. Start the backend server:
111
+ 3 . Run the backend API server tests :
106
112
107
- ```
108
- ./target/debug/server
109
- ```
113
+ ```
114
+ cargo test
115
+ ```
110
116
111
- 7. **Optionally** start a local frontend:
117
+ ### Hosting crates.io locally
112
118
113
- ```
114
- yarn run start:local
115
- ```
119
+ After following the instructions described in "Working on the Backend":
116
120
117
- ### Running Tests
121
+ 1 . Make sure your local postgres instance is running and create a database for
122
+ use with the local crates.io instance. ` cargo_registry ` is a good name to
123
+ use. You can do this by running ` psql ` to connect to ` postgres ` and run:
118
124
119
- 1. Configure the location of the test database. Create a database other than
120
- your development database, since running the tests will clear out the data.
121
- For example, to use a database named `cargo_registry_test`, create it in
122
- postgres by running `psql` to connect to postgres, then run
123
- `CREATE DATABASE cargo_registry_test;`. The test harness will ensure that
124
- migrations are run.
125
+ ```
126
+ CREATE DATABASE cargo_registry;
127
+ ```
125
128
126
- In your `.env` file, specify your test database URL. Here's an example,
127
- assuming your test database is named `cargo_registry_test`:
129
+ 2 . Modify the ` .env ` configuration file's ` DATABASE_URL ` setting to point
130
+ to the local postgres instance with the database you want to use. If you've
131
+ followed these instructions it should likely look like:
128
132
129
- ```
130
- export TEST_DATABASE_URL =postgres://postgres@localhost/cargo_registry_test
131
- ```
133
+ ```
134
+ export DATABASE_URL =postgres://postgres@localhost/cargo_registry
135
+ ```
132
136
133
- 2. In your `.env` file, set the s3 bucket to `alexcrichton-test`. No actual
134
- requests to s3 will be made; the requests and responses are recorded in
135
- files in `tests/http-data` and the s3 bucket name needs to match the
136
- requests in the files.
137
+ 3 . Set up the git index:
137
138
138
- ```
139
- export S3_BUCKET=alexcrichton-test
140
- ```
139
+ ```
140
+ ./script/init-local-index.sh
141
+ ```
141
142
142
- 3. Run the backend API server tests:
143
+ But * do not* modify your ` ~/.cargo/config ` yet (but record the instructions
144
+ shown at the end of this step as you'll need them later).
145
+
146
+ 4 . Build the server:
147
+
148
+ ```
149
+ cargo build
150
+ ```
151
+
152
+ On OS X 10.11, you will need to install the openssl headers first, and tell
153
+ cargo where to find them. See https://github.com/sfackler/rust-openssl#osx .
154
+
155
+ 5 . Modify your ` ~/.cargo/config ` after successfully building crates.io
156
+ following the instructions shown at the end of Step 3.
157
+
158
+ 5 . Run the migrations:
159
+
160
+ ```
161
+ ./target/debug/migrate
162
+ ```
163
+
164
+ 6 . Start the backend server:
165
+
166
+ ```
167
+ ./target/debug/server
168
+ ```
169
+
170
+ 7 . ** Optionally** start a local frontend:
171
+
172
+ ```
173
+ yarn run start:local
174
+ ```
143
175
144
- ```
145
- cargo test
146
- ```
147
-
148
176
## Categories
149
177
150
178
The list of categories available on crates.io is stored in
0 commit comments