Skip to content

chore(deps): bump sqlx from 0.7.4 to 0.8.2 #487

chore(deps): bump sqlx from 0.7.4 to 0.8.2

chore(deps): bump sqlx from 0.7.4 to 0.8.2 #487

Workflow file for this run

name: server
on:
push:
branches:
- main
pull_request:
branches:
- "*"
env:
CARGO_TERM_COLOR: always
SQLX_VERSION: 0.8.2
SQLX_FEATURES: postgres
jobs:
fmt-lint-test:
name: format, lint and test
runs-on: ubuntu-latest
services:
postgres:
image: postgres:14
env:
POSTGRES_USER: ${{ secrets.CI_DATABASE_USERNAME || 'postgres' }}
POSTGRES_PASSWORD: ${{ secrets.CI_DATABASE_PASSWORD || github.sha }}
POSTGRES_DB: ${{ secrets.CI_DATABASE_NAME || 'test-db' }}
ports:
- 5432:5432
env:
POSTGRES_USER: ${{ secrets.CI_DATABASE_USERNAME || 'postgres' }}
POSTGRES_PASSWORD: ${{ secrets.CI_DATABASE_PASSWORD || github.sha }}
POSTGRES_DB: ${{ secrets.CI_DATABASE_NAME || 'test-db' }}
POSTGRES_HOST: localhost
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup .env
run: ./scripts/create_env.sh
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: llvm-tools-preview
- uses: Swatinem/rust-cache@v2
with:
cache-targets: true
- name: Check Format
run: cargo fmt --all -- --check
- uses: taiki-e/install-action@nextest
- name: Cache sqlx-cli
uses: actions/cache@v4
id: cache-sqlx
with:
path: |
~/.cargo/bin/sqlx
~/.cargo/bin/cargo-sqlx
key: ${{ runner.os }}-sqlx-${{ env.SQLX_VERSION }}
- name: Install sqlx-cli
if: steps.cache-sqlx.outputs.cache-hit == false
run: |
cargo install sqlx-cli \
--force \
--version=${{ env.SQLX_VERSION }} \
--features ${{ env.SQLX_FEATURES }} \
--no-default-features \
--locked
- name: Migrate database
run: |
sudo apt-get install libpq-dev -y
./scripts/init_db.sh
- name: Lint
if: github.actor != 'dependabot[bot]'
run: |
cargo clippy -- -D warnings
- name: Check sqlx offline query
if: github.actor != 'dependabot[bot]'
run: |
cd apps/server
cargo sqlx prepare --check -- --lib
- name: Run Tests
run: |
cd apps/server
cargo nextest run
build-deploy:
name: build and deploy
runs-on: ubuntu-latest
needs:
- fmt-lint-test
environment: production
if: github.ref == 'refs/heads/main'
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login
id: auth
uses: google-github-actions/auth@v2
with:
token_format: access_token
workload_identity_provider: ${{ secrets.GCP_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_DEPLOY_SERVICE_ACCOUNT }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
with:
install_components: beta
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker Image Metadata
id: backend-meta
uses: docker/metadata-action@v4
with:
images: |
${{ vars.CLOUD_RUN_APP_IMAGE }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=sha
- name: Docker Image Metadata
id: otel-collector-meta
uses: docker/metadata-action@v4
with:
images: |
${{ vars.CLOUD_RUN_OTEL_COLLECTOR_IMAGE }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=sha
- name: Login to GAR
uses: docker/login-action@v3
with:
registry: us-central1-docker.pkg.dev
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}
- name: Build production image
uses: docker/build-push-action@v5
with:
context: .
provenance: false
file: apps/server/Dockerfile
target: runtime
push: true
tags: ${{ steps.backend-meta.outputs.tags }}
labels: ${{ steps.backend-meta.outputs.labels }}
cache-from: type=registry,ref=${{ vars.CLOUD_RUN_APP_IMAGE }}:buildcache
cache-to: type=registry,ref=${{ vars.CLOUD_RUN_APP_IMAGE }}:buildcache,mode=max
- name: Build collector image
uses: docker/build-push-action@v5
with:
context: .
provenance: false
file: otel-collector/Dockerfile
push: true
tags: ${{ steps.otel-collector-meta.outputs.tags }}
labels: ${{ steps.otel-collector-meta.outputs.labels }}
cache-from: type=registry,ref=${{ vars.CLOUD_RUN_OTEL_COLLECTOR_IMAGE }}:buildcache
cache-to: type=registry,ref=${{ vars.CLOUD_RUN_OTEL_COLLECTOR_IMAGE }}:buildcache,mode=max
- name: Replace variables in backend-service.yaml
run: |
sed -i s#%OTEL_COLLECTOR_IMAGE%#${{ fromJSON(steps.otel-collector-meta.outputs.json).tags[1] }}#g backend-service.yaml
sed -i s#%APP_IMAGE%#${{ fromJSON(steps.backend-meta.outputs.json).tags[1] }}#g backend-service.yaml
sed -i s#%SERVICE_ACCOUNT%#${{ secrets.CLOUD_RUN_SERVICE_ACCOUNT }}#g backend-service.yaml
sed -i s#%APP__APPLICATION__PORT%#${{ secrets.APP__APPLICATION__PORT }}#g backend-service.yaml
sed -i s#%APP__APPLICATION__BASE_URL%#${{ secrets.APP__APPLICATION__BASE_URL }}#g backend-service.yaml
sed -i s#%APP__BIGCOMMERCE__INSTALL_REDIRECT_URI%#${{ secrets.APP__BIGCOMMERCE__INSTALL_REDIRECT_URI }}#g backend-service.yaml
- name: Deploy Cloud Run
run: |
gcloud run services replace backend-service.yaml --region=us-central1 --project=${{ secrets.GCP_PROJECT_ID }}
coverage:
name: coverage
runs-on: ubuntu-latest
needs:
- fmt-lint-test
services:
postgres:
image: postgres:14
env:
POSTGRES_USER: ${{ secrets.CI_DATABASE_USERNAME || 'postgres' }}
POSTGRES_PASSWORD: ${{ secrets.CI_DATABASE_PASSWORD || github.sha }}
POSTGRES_DB: ${{ secrets.CI_DATABASE_NAME || 'test-db' }}
ports:
- 5432:5432
if: github.actor != 'dependabot[bot]'
env:
POSTGRES_USER: ${{ secrets.CI_DATABASE_USERNAME || 'postgres' }}
POSTGRES_PASSWORD: ${{ secrets.CI_DATABASE_PASSWORD || github.sha }}
POSTGRES_DB: ${{ secrets.CI_DATABASE_NAME || 'test-db' }}
POSTGRES_HOST: localhost
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup .env
run: ./scripts/create_env.sh
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: llvm-tools-preview
- uses: Swatinem/rust-cache@v2
with:
cache-targets: true
- uses: taiki-e/install-action@cargo-llvm-cov
- uses: taiki-e/install-action@nextest
- name: Cache sqlx-cli
uses: actions/cache@v4
id: cache-sqlx
with:
path: |
~/.cargo/bin/sqlx
~/.cargo/bin/cargo-sqlx
key: ${{ runner.os }}-sqlx-${{ env.SQLX_VERSION }}
- name: Install sqlx-cli
if: steps.cache-sqlx.outputs.cache-hit == false
run: |
cargo install sqlx-cli \
--force \
--version=${{ env.SQLX_VERSION }} \
--features ${{ env.SQLX_FEATURES }} \
--no-default-features \
--locked
- name: Migrate database
run: |
sudo apt-get install libpq-dev -y
SKIP_DOCKER=true ./scripts/init_db.sh
- name: Test
run: |
cd apps/server/
cargo llvm-cov nextest --all-features --lcov --output-path lcov.info
- name: Upload coverage to Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
file: apps/server/lcov.info