Skip to content

CI

CI #4713

Workflow file for this run

name: CI
on:
push:
pull_request:
schedule:
- cron: "0 0 * * *"
env:
RUST_BACKTRACE: 1
DOCSRS_PREFIX: ignored/cratesfyi-prefix
DOCSRS_DATABASE_URL: postgresql://cratesfyi:password@localhost:15432
DOCSRS_LOG: docs_rs=debug,rustwide=info
AWS_ACCESS_KEY_ID: cratesfyi
AWS_SECRET_ACCESS_KEY: secret_key
S3_ENDPOINT: http://localhost:9000
DOCSRS_INCLUDE_DEFAULT_TARGETS: false
DOCSRS_DOCKER_IMAGE: ghcr.io/rust-lang/crates-build-env/linux-micro
SENTRY_ENVIRONMENT: dev
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- id: install
run: |
rustup override set stable
rustup update stable
- name: restore build & cargo cache
uses: Swatinem/rust-cache@v2
- name: Build
run: cargo build --workspace --locked
- name: compile test binaries
run: |
cargo test --no-run
mkdir ./test-binaries/
find ./target \
-name "docs_rs*" \
-executable -type f \
-exec cp {} ./test-binaries/ \;
- uses: actions/upload-artifact@v3
name: set up test binaries to cache
with:
name: test-binaries-${{ github.sha }}
path: ./test-binaries/
retention-days: 1
test:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
- name: get test binaries from cache
uses: actions/download-artifact@v3
with:
name: test-binaries-${{ github.sha }}
path: ./test-binaries/
- name: Launch postgres and min.io
run: |
cp .env.sample .env
mkdir -p ${DOCSRS_PREFIX}/public-html
docker-compose up -d db s3
# Give the database enough time to start up
sleep 5
# Make sure the database is actually working
psql "${DOCSRS_DATABASE_URL}"
- name: run tests
shell: bash
run: |
for f in ./test-binaries/*; do
echo "running $f"
chmod +x $f # GH action artifacts don't handle permissions
$f || exit 1
done
- name: Clean up the database
run: docker-compose down --volumes
build_tests:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
- name: get test binaries from cache
uses: actions/download-artifact@v3
with:
name: test-binaries-${{ github.sha }}
path: ./test-binaries/
- name: Launch postgres and min.io
run: |
cp .env.sample .env
mkdir -p ${DOCSRS_PREFIX}/public-html
docker-compose up -d db s3
# Give the database enough time to start up
sleep 5
# Make sure the database is actually working
psql "${DOCSRS_DATABASE_URL}"
- name: slow tests
env:
DOCSRS_INCLUDE_DEFAULT_TARGETS: true
run: |
for f in ./test-binaries/*; do
echo "running $f"
chmod +x $f # GH action artifacts don't handle permissions
# run build-tests. Limited to one thread since we don't support parallel builds.
$f --ignored --test-threads=1 || exit 1
done
- name: Clean up the database
run: docker-compose down --volumes
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- id: install
run: |
rustup override set stable
rustup update stable
rustup component add rustfmt
- run: cargo fmt -- --check
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- id: install
run: |
rustup override set stable
rustup update stable
rustup component add clippy
- name: restore build & cargo cache
uses: Swatinem/rust-cache@v2
- run: cargo clippy --all-features --all-targets --workspace --locked -- -D warnings