Skip to content

Commit 42ca958

Browse files
committed
test
1 parent e4b6ba4 commit 42ca958

File tree

2 files changed

+51
-23
lines changed

2 files changed

+51
-23
lines changed

.github/workflows/ci.yml

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,6 @@ jobs:
1717
steps:
1818
- uses: actions/checkout@v5
1919

20-
# We check that all github actions workflows have valid syntax
21-
- name: Validate YAML file
22-
uses: raven-actions/actionlint@v2
23-
with:
24-
files: .github/workflow/*
25-
flags: "-ignore SC2086" # ignore some shellcheck errors
26-
2720
- name: install `just`
2821
run: sudo snap install --edge --classic just
2922

@@ -37,24 +30,14 @@ jobs:
3730
- name: Set up Docker Buildx
3831
uses: docker/setup-buildx-action@v3
3932

40-
- name: Launch postgres
41-
run: just _ensure_db_and_s3_are_running
42-
4333
- name: install SQLX CLI
4434
run: cargo binstall sqlx-cli
4535

46-
- name: run database migrations
47-
run: cargo sqlx migrate run --database-url $DOCSRS_DATABASE_URL
48-
49-
- name: run sqlx prepare --check
50-
run: just sqlx-prepare
51-
52-
- name: test reverse migrations
36+
- name: run sqlx migration up & down
5337
run: |
54-
# --target 0 means "revert everything"
55-
cargo sqlx migrate revert \
56-
--database-url $DOCSRS_DATABASE_URL \
57-
--target-version 0
38+
just sqlx-migrate-run \
39+
sqlx-check \
40+
sqlx-migrate-revert
5841
5942
- name: shut down test environment
6043
if: ${{ always() }}
@@ -122,6 +105,7 @@ jobs:
122105
- run: just lint
123106

124107
lint-js:
108+
name: js linters
125109
runs-on: ubuntu-latest
126110
steps:
127111
- uses: actions/checkout@v5
@@ -132,3 +116,16 @@ jobs:
132116
run: sudo snap install --edge --classic just
133117

134118
- 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

justfiles/testing.just

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,48 @@
11
# just commands for CI & local development
2+
set dotenv-load := true
3+
set dotenv-override := true
24

5+
# some environment variables that are needed for _local_ commands
6+
# these are defaults that can be overwritten in your local .env file
7+
export DOCSRS_INCLUDE_DEFAULT_TARGETS := env("DOCSRS_INCLUDE_DEFAULT_TARGETS", "false")
8+
export DOCSRS_LOG := env("DOCSRS_LOG", "docs_rs=debug,rustwide=info")
9+
export RUST_BACKTRACE := env("RUST_BACKTRACE", "1")
10+
export DOCSRS_PREFIX := env("DOCSRS_PREFIX", "ignored/cratesfyi-prefix")
11+
12+
# database & s3 settings for local testing, to connect to the DB & S3/minio instance
13+
# configured in docker-compose.yml
14+
export DOCSRS_DATABASE_URL := env("DOCSRS_DATABASE_URL", "postgresql://cratesfyi:password@localhost:15432")
15+
export AWS_ACCESS_KEY_ID := env("AWS_ACCESS_KEY_ID", "cratesfyi")
16+
export AWS_SECRET_ACCESS_KEY := env("AWS_SECRET_ACCESS_KEY", "secret_key")
17+
export S3_ENDPOINT := env("S3_ENDPOINT", "http://localhost:9000")
318

419

520
[group('testing')]
6-
sqlx-prepare *args:
21+
[group('sqlx')]
22+
sqlx-prepare *args: _ensure_db_and_s3_are_running
723
cargo sqlx prepare \
824
--database-url $DOCSRS_DATABASE_URL \
925
--workspace {{ args }} \
1026
-- --all-targets --all-features
1127

1228
[group('testing')]
29+
[group('sqlx')]
1330
sqlx-check:
14-
just sqlx-prepare -check
31+
just sqlx-prepare --check
32+
33+
[group('testing')]
34+
[group('sqlx')]
35+
sqlx-migrate-run: _ensure_db_and_s3_are_running
36+
cargo sqlx migrate run --database-url $DOCSRS_DATABASE_URL
37+
38+
[group('testing')]
39+
[group('sqlx')]
40+
sqlx-migrate-revert target="0": _ensure_db_and_s3_are_running
41+
# --target 0 means "revert everything"
42+
cargo sqlx migrate revert \
43+
--database-url $DOCSRS_DATABASE_URL \
44+
--target-version {{ target }}
45+
1546

1647
# Format the code using `cargo fmt`.
1748
[group('testing')]

0 commit comments

Comments
 (0)