Skip to content

Commit 2dcd1d3

Browse files
committed
Standardize environment variables on DOCSRS_
This changes the following env variables used in prod: - CRATESFYI_PREFIX - CRATESFYI_DATABASE_URL - CRATESFYI_GITHUB_ACCESSTOKEN - CRATESFYI_RUSTWIDE_WORKSPACE - CRATESFYI_TOOLCHAIN - DOCS_RS_BUILD_CPU_LIMIT Before deploying, we should set the new names of all these variables. After deploying, we can delete the old names.
1 parent 379c29a commit 2dcd1d3

File tree

8 files changed

+27
-27
lines changed

8 files changed

+27
-27
lines changed

.env.sample

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
CRATESFYI_PREFIX=ignored/cratesfyi-prefix
2-
CRATESFYI_DATABASE_URL=postgresql://cratesfyi:password@localhost:15432
1+
DOCSRS_PREFIX=ignored/cratesfyi-prefix
2+
DOCSRS_DATABASE_URL=postgresql://cratesfyi:password@localhost:15432
33
DOCSRS_LOG=docs_rs,rustwide=info
44
AWS_ACCESS_KEY_ID=cratesfyi
55
AWS_SECRET_ACCESS_KEY=secret_key

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ jobs:
5858
run: |
5959
cp .env.sample .env
6060
. .env
61-
mkdir -p ${CRATESFYI_PREFIX}/public-html
61+
mkdir -p ${DOCSRS_PREFIX}/public-html
6262
docker-compose up -d db s3
6363
# Give the database enough time to start up
6464
sleep 5
6565
# Make sure the database is actually working
66-
psql "${CRATESFYI_DATABASE_URL}"
66+
psql "${DOCSRS_DATABASE_URL}"
6767
6868
- name: run tests
6969
shell: bash

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ git clone https://github.com/rust-lang/docs.rs.git docs.rs
5858
cd docs.rs
5959
# Configure the default settings for external services
6060
cp .env.sample .env
61-
# Create the CRATESFYI_PREFIX directory
61+
# Create the DOCSRS_PREFIX directory
6262
mkdir -p ignored/cratesfyi-prefix/crates.io-index
6363
# Builds the docs.rs binary
6464
cargo build
@@ -101,7 +101,7 @@ cargo test
101101
```
102102

103103
Most tests require access to the database. To run them, set the
104-
`CRATESFYI_DATABASE_URL` in `.env` to the url of a PostgreSQL database,
104+
`DOCSRS_DATABASE_URL` in `.env` to the url of a PostgreSQL database,
105105
and set the `AWS_ACCESS_KEY_ID`, `S3_ENDPOINT`, and `AWS_SECRET_ACCESS_KEY` variables.
106106
We have some reasonable default parameters in `.env.sample`.
107107

@@ -188,7 +188,7 @@ cargo run -- build crate --local /path/to/source
188188
cargo run -- database add-directory <DIRECTORY> [PREFIX]
189189

190190
# Updates repository stats for crates.
191-
# You need to set the CRATESFYI_GITHUB_ACCESSTOKEN
191+
# You need to set the DOCSRS_GITHUB_ACCESSTOKEN
192192
# environment variable in order to run this command.
193193
# Set DOCSRS_GITLAB_ACCESSTOKEN to raise the rate limit for GitLab repositories,
194194
# or leave it blank to fetch repositories at a slower rate.
@@ -200,7 +200,7 @@ with the `psql` command.
200200

201201
```sh
202202
. .env
203-
psql $CRATESFYI_DATABASE_URL
203+
psql $DOCSRS_DATABASE_URL
204204
```
205205

206206
The database contains a blacklist of crates that should not be built.

crates/metadata/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
fn main() {
22
// Set the host target
33
println!(
4-
"cargo:rustc-env=DOCS_RS_METADATA_HOST_TARGET={}",
4+
"cargo:rustc-env=DOCSRS_METADATA_HOST_TARGET={}",
55
std::env::var("TARGET").unwrap(),
66
);
77
// This only needs to be rerun if the TARGET changed, in which case cargo reruns it anyway.

crates/metadata/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ use toml::Value;
5050
/// This is directly passed on from the Cargo [`TARGET`] variable.
5151
///
5252
/// [`TARGET`]: https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-build-scripts
53-
pub const HOST_TARGET: &str = env!("DOCS_RS_METADATA_HOST_TARGET");
53+
pub const HOST_TARGET: &str = env!("DOCSRS_METADATA_HOST_TARGET");
5454
/// The targets that are built if no `targets` section is specified.
5555
///
5656
/// Currently, this is guaranteed to have only [tier one] targets.

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ services:
1616
- ".rustwide-docker:/opt/docsrs/rustwide"
1717
- "cratesio-index:/opt/docsrs/prefix/crates.io-index"
1818
environment:
19-
CRATESFYI_RUSTWIDE_WORKSPACE: /opt/docsrs/rustwide
20-
CRATESFYI_DATABASE_URL: postgresql://cratesfyi:password@db
19+
DOCSRS_RUSTWIDE_WORKSPACE: /opt/docsrs/rustwide
20+
DOCSRS_DATABASE_URL: postgresql://cratesfyi:password@db
2121
DOCSRS_STORAGE_BACKEND: s3
2222
S3_ENDPOINT: http://s3:9000
2323
AWS_ACCESS_KEY_ID: cratesfyi

dockerfiles/entrypoint.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
set -euv
44

5-
export CRATESFYI_PREFIX=/opt/docsrs/prefix
6-
export DOCS_RS_DOCKER=true
7-
export DOCSRS_LOG=${DOCSRS_LOG-cratesfyi,rustwide=info}
5+
export DOCSRS_PREFIX=/opt/docsrs/prefix
6+
export DOCSRS_DOCKER=true
7+
export DOCSRS_LOG=${DOCSRS_LOG-"docs-rs,rustwide=info"}
88
export PATH="$PATH:/build/target/release"
99

1010
# Try migrating the database multiple times if it fails
@@ -27,10 +27,10 @@ while true; do
2727
done
2828
set -e
2929

30-
if ! [ -d "${CRATESFYI_PREFIX}/crates.io-index/.git" ]; then
31-
git clone https://github.com/rust-lang/crates.io-index "${CRATESFYI_PREFIX}/crates.io-index"
30+
if ! [ -d "${DOCSRS_PREFIX}/crates.io-index/.git" ]; then
31+
git clone https://github.com/rust-lang/crates.io-index "${DOCSRS_PREFIX}/crates.io-index"
3232
# Prevent new crates built before the container creation to be built
33-
git --git-dir="$CRATESFYI_PREFIX/crates.io-index/.git" branch crates-index-diff_last-seen
33+
git --git-dir="$DOCSRS_PREFIX/crates.io-index/.git" branch crates-index-diff_last-seen
3434
fi
3535

3636
cratesfyi build update-toolchain --only-first-time

src/config.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,16 @@ pub struct Config {
6666

6767
impl Config {
6868
pub fn from_env() -> Result<Self, Error> {
69-
let prefix: PathBuf = require_env("CRATESFYI_PREFIX")?;
69+
let prefix: PathBuf = require_env("DOCSRS_PREFIX")?;
7070

7171
Ok(Self {
7272
build_attempts: env("DOCSRS_BUILD_ATTEMPTS", 5)?,
7373

74-
prefix: prefix.clone(),
7574
registry_index_path: env("REGISTRY_INDEX_PATH", prefix.join("crates.io-index"))?,
7675
registry_url: maybe_env("REGISTRY_URL")?,
76+
prefix,
7777

78-
database_url: require_env("CRATESFYI_DATABASE_URL")?,
78+
database_url: require_env("DOCSRS_DATABASE_URL")?,
7979
max_pool_size: env("DOCSRS_MAX_POOL_SIZE", 90)?,
8080
min_pool_idle: env("DOCSRS_MIN_POOL_IDLE", 10)?,
8181

@@ -90,7 +90,7 @@ impl Config {
9090
#[cfg(test)]
9191
s3_bucket_is_temporary: false,
9292

93-
github_accesstoken: maybe_env("CRATESFYI_GITHUB_ACCESSTOKEN")?,
93+
github_accesstoken: maybe_env("DOCSRS_GITHUB_ACCESSTOKEN")?,
9494
github_updater_min_rate_limit: env("DOCSRS_GITHUB_UPDATER_MIN_RATE_LIMIT", 2500)?,
9595

9696
gitlab_accesstoken: maybe_env("DOCSRS_GITLAB_ACCESSTOKEN")?,
@@ -106,12 +106,12 @@ impl Config {
106106

107107
csp_report_only: env("DOCSRS_CSP_REPORT_ONLY", false)?,
108108

109-
rustwide_workspace: env("CRATESFYI_RUSTWIDE_WORKSPACE", PathBuf::from(".workspace"))?,
110-
inside_docker: env("DOCS_RS_DOCKER", false)?,
111-
docker_image: maybe_env("DOCS_RS_LOCAL_DOCKER_IMAGE")?
109+
rustwide_workspace: env("DOCSRS_RUSTWIDE_WORKSPACE", PathBuf::from(".workspace"))?,
110+
inside_docker: env("DOCSRS_DOCKER", false)?,
111+
docker_image: maybe_env("DOCSRS_LOCAL_DOCKER_IMAGE")?
112112
.or(maybe_env("DOCSRS_DOCKER_IMAGE")?),
113-
toolchain: env("CRATESFYI_TOOLCHAIN", "nightly".to_string())?,
114-
build_cpu_limit: maybe_env("DOCS_RS_BUILD_CPU_LIMIT")?,
113+
toolchain: env("DOCSRS_TOOLCHAIN", "nightly".to_string())?,
114+
build_cpu_limit: maybe_env("DOCSRS_BUILD_CPU_LIMIT")?,
115115
include_default_targets: env("DOCSRS_INCLUDE_DEFAULT_TARGETS", true)?,
116116
disable_memory_limit: env("DOCSRS_DISABLE_MEMORY_LIMIT", false)?,
117117
})

0 commit comments

Comments
 (0)