Skip to content

Commit

Permalink
chore: update github workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
hopeyen committed Feb 15, 2024
1 parent 3df08cd commit 47faba1
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

strategy:
matrix:
target: [file-exchange]
target: [file-exchange, file-service]

permissions:
packages: write
Expand Down
17 changes: 13 additions & 4 deletions .github/workflows/gen-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ jobs:
build-linux:
runs-on: ubuntu-latest

strategy:
matrix:
target: [file-exchange, file-service]

steps:
- uses: actions/checkout@v3
- name: Setup Rust
Expand All @@ -23,11 +27,16 @@ jobs:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./target/release/file-exchange
asset_name: file-exchange-${{ github.event.release.tag_name }}-ubuntu
asset_path: ./target/release/${{matrix.target}}
asset_name: ${{matrix.target}}-${{ github.event.release.tag_name }}-ubuntu
asset_content_type: binary/octet-stream
build-macos:
runs-on: macos-latest

strategy:
matrix:
target: [file-exchange, file-service]

steps:
- uses: actions/checkout@v3
- name: Setup Rust
Expand All @@ -43,6 +52,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./target/release/file-exchange
asset_name: file-exchange-${{ github.event.release.tag_name }}-macos
asset_path: ./target/release/${{matrix.target}}
asset_name: ${{matrix.target}}-${{ github.event.release.tag_name }}-macos
asset_content_type: binary/octet-stream
58 changes: 40 additions & 18 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: tests

on:
push:
branches: [ main, dev ]
branches: [ main, dev, 'hope/test-**' ]
pull_request:
branches:
- 'hope/test-**'
- '**'
workflow_dispatch:

jobs:
Expand All @@ -20,9 +20,21 @@ jobs:
rustup component add rustfmt
cargo fmt --all -- --check
clippy:
name: cargo clippy
sqlx:
name: prepare query metadata
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15
env:
POSTGRES_HOST_AUTH_METHOD: trust
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
container:
image: rust:1.74-bookworm
env:
Expand All @@ -37,11 +49,23 @@ jobs:
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}
- run: |
rustup component add clippy
# Temporarily allowing dead-code, while denying all other warnings
cargo clippy --all-features --all-targets -- -A dead-code -D warnings
key: ${{ runner.os }}-sqlx-prepare-${{ hashFiles('**/Cargo.lock') }}
- name: Install sqlx
run: cargo install sqlx-cli --no-default-features --features postgres
- name: Run the test sqlx migrations
run: cargo sqlx migrate run --source file-service
- name: Check that the sqlx prepared query metadata is up-to-date
run: cargo sqlx prepare --workspace --check -- --all-targets --all-features

clippy:
name: cargo clippy
runs-on: ubuntu-latest
container:
image: rust:1.74-bookworm
env:
DATABASE_URL: postgres://postgres@postgres:5432
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
Expand All @@ -50,14 +74,12 @@ jobs:
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-sqlx-prepare-${{ hashFiles('**/Cargo.lock') }}
- name: Install sqlx
run: cargo install sqlx-cli --no-default-features --features postgres
- name: Run the test sqlx migrations
run: cargo sqlx migrate run
- name: Check that the sqlx prepared query metadata is up-to-date
run: cargo sqlx prepare --workspace --check -- --all-targets --all-features

key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}
- run: |
rustup component add clippy
# Temporarily allowing dead-code, while denying all other warnings
cargo clippy --all-features --all-targets -- -A dead-code -D warnings
test-and-coverage:
name: cargo test and coverage
runs-on: ubuntu-latest
Expand Down Expand Up @@ -97,7 +119,7 @@ jobs:
- name: Install sqlx
run: cargo install sqlx-cli --no-default-features --features postgres
- name: Run the test sqlx migrations
run: cargo sqlx migrate run
run: cargo sqlx migrate run --source file-service
- name: Run tests and generate coverage report
run: cargo llvm-cov test --all-features --workspace --lcov --output-path lcov.info
- name: Test documentation code snippets
Expand Down
20 changes: 20 additions & 0 deletions Dockerfile.file-service
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM rust:1.74-bookworm as build

WORKDIR /root
COPY . .

RUN ls -a

ENV SQLX_OFFLINE=true
RUN cargo build --release --bin file-service

########################################################################################

FROM debian:bookworm-slim

RUN apt-get update && apt-get install -y --no-install-recommends \
openssl ca-certificates \
&& rm -rf /var/lib/apt/lists/*
COPY --from=build /root/target/release/file-service /usr/local/bin/file-service

ENTRYPOINT [ "/usr/local/bin/file-service" ]
2 changes: 1 addition & 1 deletion docs/database_migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ Simple option: run general installation that supports all databases supported by

### Run the migration

Run `sqlx migrate run`
Run `sqlx migrate run --source file-service/`

0 comments on commit 47faba1

Please sign in to comment.