Skip to content

Commit 76793fe

Browse files
committed
extend&fix Dockerfile, extended compose.yml, new just recipes
1 parent cf1eecc commit 76793fe

33 files changed

+952
-463
lines changed

.docker.env.sample

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# environment overrides for the app instances running inside docker compose
2+
DOCSRS_LOG=docs_rs=debug,rustwide=info
3+
DOCSRS_INCLUDE_DEFAULT_TARGETS=false
4+
DOCSRS_DOCKER_IMAGE=ghcr.io/rust-lang/crates-build-env/linux-micro
5+
# To build with a PR that hasn't landed in a rust dist toolchain yet,
6+
# you can set this to the git sha of a try build:
7+
# https://forge.rust-lang.org/infra/docs/rustc-ci.html#try-builds
8+
DOCSRS_TOOLCHAIN=nightly
9+
10+
# for the registry watcher, automatically queued reqbuidls.
11+
DOCSRS_MAX_QUEUED_REBUILDS: 10
12+

.dockerignore

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
/target/
1+
/.docker.env
2+
/.env.*
3+
/.envrc
24
/.rustwide
35
/.rustwide-docker
46
/Justfile
57
/LICENSE
68
/README.md
9+
/clippy.toml
710
/docker-compose.yml
11+
/dockerfiles/
812
/docs/
913
/ignored
14+
/justfiles/
1015
/mcps
16+
/target/
1117
/triagebot.toml
12-
/clippy.toml
18+
archive_cache

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,9 @@ insert_final_newline = true
88
indent_style = space
99
indent_size = 4
1010

11+
[Justfile]
12+
indent_size = 2
13+
1114
[*.js]
1215
max_line_length = 100
16+

.env.sample

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
1-
export DOCSRS_PREFIX=ignored/cratesfyi-prefix
2-
export DOCSRS_DATABASE_URL=postgresql://cratesfyi:password@localhost:15432
1+
# environment overrides for local development outside docker.
2+
DOCSRS_PREFIX=ignored/cratesfyi-prefix
3+
DOCSRS_DATABASE_URL=postgresql://cratesfyi:password@localhost:15432
34

45
# for local development with sqlx
5-
export DATABASE_URL=postgresql://cratesfyi:password@localhost:15432
6+
DATABASE_URL=postgresql://cratesfyi:password@localhost:15432
67

7-
export DOCSRS_LOG=docs_rs=debug,rustwide=info
8+
DOCSRS_LOG=docs_rs=debug,rustwide=info
9+
AWS_ACCESS_KEY_ID=cratesfyi
10+
AWS_SECRET_ACCESS_KEY=secret_key
11+
S3_ENDPOINT=http://localhost:9000
12+
DOCSRS_S3_STATIC_ROOT_PATH=http://localhost:9000/rust-docs-rs
13+
14+
15+
# build specific
16+
DOCSRS_INCLUDE_DEFAULT_TARGETS=false
17+
DOCSRS_DOCKER_IMAGE=ghcr.io/rust-lang/crates-build-env/linux-micro
18+
SENTRY_ENVIRONMENT=dev
819
# To build with a PR that hasn't landed in a rust dist toolchain yet,
920
# you can set this to the git sha of a try build:
1021
# https://forge.rust-lang.org/infra/docs/rustc-ci.html#try-builds
11-
export DOCSRS_TOOLCHAIN=nightly
12-
export AWS_ACCESS_KEY_ID=cratesfyi
13-
export AWS_SECRET_ACCESS_KEY=secret_key
14-
export S3_ENDPOINT=http://localhost:9000
15-
export DOCSRS_S3_STATIC_ROOT_PATH=http://localhost:9000/rust-docs-rs
16-
export DOCSRS_INCLUDE_DEFAULT_TARGETS=false
17-
export DOCSRS_DOCKER_IMAGE=ghcr.io/rust-lang/crates-build-env/linux-micro
18-
export SENTRY_ENVIRONMENT=dev
22+
DOCSRS_TOOLCHAIN=nightly
23+
24+
# NOTE: when running services in docker-compose, you can override the settings in
25+
# `.docker.env`, you'll fine an example in `.docker.env.sample`.

.git_hooks/pre-commit

Lines changed: 0 additions & 17 deletions
This file was deleted.

.git_hooks/pre-push

Lines changed: 0 additions & 17 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 54 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -9,130 +9,88 @@ on:
99
- cron: "0 0 * * *"
1010

1111
env:
12-
RUST_BACKTRACE: 1
1312
RUST_CACHE_KEY: rust-cache-20241114
14-
DOCSRS_PREFIX: ignored/cratesfyi-prefix
15-
DOCSRS_DATABASE_URL: postgresql://cratesfyi:password@localhost:15432
16-
DOCSRS_LOG: docs_rs=debug,rustwide=info
17-
AWS_ACCESS_KEY_ID: cratesfyi
18-
AWS_SECRET_ACCESS_KEY: secret_key
19-
S3_ENDPOINT: http://localhost:9000
20-
DOCSRS_INCLUDE_DEFAULT_TARGETS: false
21-
DOCSRS_DOCKER_IMAGE: ghcr.io/rust-lang/crates-build-env/linux-micro
22-
SENTRY_ENVIRONMENT: dev
2313

2414
jobs:
2515
sqlx:
2616
runs-on: ubuntu-latest
2717
steps:
2818
- uses: actions/checkout@v5
2919

30-
# We check that all github actions workflows have valid syntax
31-
- name: Validate YAML file
32-
uses: raven-actions/actionlint@v2
33-
with:
34-
files: .github/workflow/*
35-
flags: "-ignore SC2086" # ignore some shellcheck errors
36-
3720
- name: install `just`
3821
run: sudo snap install --edge --classic just
3922

23+
- uses: cargo-bins/cargo-binstall@main
24+
4025
- name: restore build & cargo cache
4126
uses: Swatinem/rust-cache@v2
4227
with:
4328
prefix-key: ${{ env.RUST_CACHE_KEY }}
4429

45-
- name: Launch postgres
46-
run: |
47-
touch .docker.env
48-
docker compose up --wait --wait-timeout 30 db
30+
- name: Set up Docker Buildx
31+
uses: docker/setup-buildx-action@v3
4932

5033
- name: install SQLX CLI
51-
run: cargo install sqlx-cli --no-default-features --features postgres
52-
53-
- name: run database migrations
54-
run: cargo sqlx migrate run --database-url $DOCSRS_DATABASE_URL
34+
run: cargo binstall sqlx-cli
5535

56-
- name: run sqlx prepare --check
57-
run: just sqlx-prepare
58-
59-
- name: test reverse migrations
36+
- name: run sqlx migration up & down
6037
run: |
61-
# --target 0 means "revert everything"
62-
cargo sqlx migrate revert \
63-
--database-url $DOCSRS_DATABASE_URL \
64-
--target-version 0
38+
just sqlx-migrate-run \
39+
sqlx-check \
40+
sqlx-migrate-revert
41+
42+
- name: shut down test environment
43+
if: ${{ always() }}
44+
run: just compose-down-and-wipe
6545

6646
test:
67-
env:
68-
SQLX_OFFLINE: 1
6947
runs-on: ubuntu-latest
7048
steps:
7149
- uses: actions/checkout@v5
7250

51+
- name: install `just`
52+
run: sudo snap install --edge --classic just
53+
7354
- name: restore build & cargo cache
7455
uses: Swatinem/rust-cache@v2
7556
with:
7657
prefix-key: ${{ env.RUST_CACHE_KEY }}
7758

78-
- name: Build
79-
run: cargo build --workspace --locked
80-
81-
- name: Launch postgres and min.io
82-
run: |
83-
touch .docker.env
84-
docker compose up --wait --wait-timeout 30 db s3
59+
- name: Set up Docker Buildx
60+
uses: docker/setup-buildx-action@v3
8561

86-
- name: run workspace tests
87-
run: |
88-
cargo test --workspace --locked --no-fail-fast
62+
- name: run tests
63+
run: just run-tests run-builder-tests
8964

90-
- name: run slow tests
91-
env:
92-
DOCSRS_INCLUDE_DEFAULT_TARGETS: true
93-
run: |
94-
cargo test --locked -- --ignored --test-threads=1
65+
- name: shut down test environment
66+
if: ${{ always() }}
67+
run: just compose-down-and-wipe
9568

9669
GUI_test:
9770
runs-on: ubuntu-latest
9871
steps:
9972
- uses: actions/checkout@v5
10073

101-
- name: restore build & cargo cache
102-
uses: Swatinem/rust-cache@v2
103-
with:
104-
prefix-key: ${{ env.RUST_CACHE_KEY }}
74+
- name: Set up Docker Buildx
75+
uses: docker/setup-buildx-action@v3
10576

106-
- name: Launch postgres and min.io
107-
run: |
108-
touch .docker.env
109-
docker compose up --wait --wait-timeout 30 db s3
77+
- name: install `just`
78+
run: sudo snap install --edge --classic just
11079

11180
- name: Run GUI tests
112-
run: ./dockerfiles/run-gui-tests.sh
113-
114-
115-
fmt:
116-
name: Rustfmt
117-
runs-on: ubuntu-latest
118-
119-
steps:
120-
- uses: actions/checkout@v5
121-
- name: update rust toolchain
122-
run: rustup component add rustfmt
81+
run: just run-gui-tests
12382

124-
- run: cargo fmt -- --check
83+
- name: shut down test environment
84+
if: ${{ always() }}
85+
run: just compose-down-and-wipe
12586

126-
clippy:
127-
name: Clippy
87+
lint-rs:
88+
name: rust linters
12889
runs-on: ubuntu-latest
12990

13091
steps:
13192
- uses: actions/checkout@v5
13293

133-
- name: update rust toolchain
134-
run: rustup component add clippy
135-
13694
- name: install `just`
13795
run: sudo snap install --edge --classic just
13896

@@ -141,13 +99,33 @@ jobs:
14199
with:
142100
prefix-key: ${{ env.RUST_CACHE_KEY }}
143101

102+
- name: Set up Docker Buildx
103+
uses: docker/setup-buildx-action@v3
104+
144105
- run: just lint
145106

146-
eslint:
107+
lint-js:
108+
name: js linters
147109
runs-on: ubuntu-latest
148110
steps:
149111
- uses: actions/checkout@v5
112+
150113
- uses: denoland/setup-deno@v2
114+
151115
- name: install `just`
152116
run: sudo snap install --edge --classic just
117+
153118
- run: just lint-js
119+
120+
lint-actions:
121+
name: gh actions linters
122+
runs-on: ubuntu-latest
123+
steps:
124+
- uses: actions/checkout@v5
125+
126+
# We check that all github actions workflows have valid syntax
127+
- name: Validate YAML file
128+
uses: raven-actions/actionlint@v2
129+
with:
130+
files: .github/workflow/*
131+
flags: "-ignore SC2086" # ignore some shellcheck errors

.github/workflows/docker.yml

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,47 @@
11
name: Docker
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
schedule:
9+
- cron: "0 0 * * *"
410

511
jobs:
612
docker:
13+
strategy:
14+
matrix:
15+
target: [
16+
"web-server",
17+
"build-server",
18+
"registry-watcher",
19+
"cli"
20+
]
721
name: Test docker image builds
822
runs-on: ubuntu-latest
923
steps:
1024
- uses: actions/checkout@v5
1125

12-
- run: docker build --target web-server -f dockerfiles/Dockerfile .
13-
- run: docker build --target build-server -f dockerfiles/Dockerfile .
14-
- run: docker build --target registry-watcher -f dockerfiles/Dockerfile .
15-
- run: docker build --target cli -f dockerfiles/Dockerfile .
26+
- name: setup docker buildx
27+
uses: docker/setup-buildx-action@v3
28+
29+
- name: build docker image
30+
uses: docker/build-push-action@v6
31+
with:
32+
context: .
33+
file: "./dockerfiles/Dockerfile"
34+
platforms: linux/amd64
35+
target: ${{ matrix.target }}
36+
build-args: |
37+
GIT_SHA=${{ github.sha }}
38+
PROFILE=release
39+
PROFILE_DIR=release
40+
load: true
41+
cache-from: type=gha
42+
cache-to: type=gha,mode=max
43+
push: false
44+
45+
# TODO: later we would set `push: true` and also provide nice tags
46+
# for the images.
47+
# Unclear is how the deploy would work then.

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ target
1111
.vagrant
1212
.rustwide
1313
.rustwide-docker
14-
.archive_cache
14+
archive_cache
1515
.workspace

0 commit comments

Comments
 (0)