Skip to content

Commit 33821b0

Browse files
Update backend.yml
1 parent 776dba0 commit 33821b0

1 file changed

Lines changed: 27 additions & 15 deletions

File tree

.github/workflows/backend.yml

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ env:
1010
CARGO_TERM_COLOR: always
1111
BINARY_NAME: backend
1212
DATABASE_URL: ${{ secrets.DATABASE_URL }}
13-
# Enable SQLx offline mode to avoid requiring a database connection during compilation
1413
SQLX_OFFLINE: true
1514

1615
jobs:
@@ -19,12 +18,14 @@ jobs:
1918
runs-on: ubuntu-latest
2019
steps:
2120
- uses: actions/checkout@v4
21+
2222
- name: Setup Rust
2323
uses: actions-rs/toolchain@v1
2424
with:
2525
profile: minimal
2626
toolchain: stable
2727
override: true
28+
2829
- name: Cache Rust dependencies
2930
uses: actions/cache@v3
3031
with:
@@ -34,18 +35,26 @@ jobs:
3435
backend/target
3536
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
3637
restore-keys: ${{ runner.os }}-cargo-
38+
39+
- name: Cache SQLx metadata
40+
uses: actions/cache@v3
41+
with:
42+
path: backend/.sqlx
43+
key: ${{ runner.os }}-sqlx-${{ hashFiles('**/*.rs', '**/migrations/**') }}
44+
restore-keys: ${{ runner.os }}-sqlx-
45+
3746
- name: Install SQLx CLI
3847
run: cargo install sqlx-cli --no-default-features --features postgres
39-
- name: Create .sqlx directory if it doesn't exist
40-
run: mkdir -p backend/.sqlx
41-
- name: Generate SQLx metadata
48+
49+
- name: Prepare SQLx metadata
4250
run: |
51+
mkdir -p backend/.sqlx
4352
cd backend
44-
cargo install sqlx-cli --no-default-features --features postgres
4553
cargo sqlx prepare -- --tests
4654
env:
4755
DATABASE_URL: ${{ secrets.DATABASE_URL }}
4856
SQLX_OFFLINE: true
57+
4958
- name: Run tests
5059
run: cd backend && cargo test --verbose
5160

@@ -89,13 +98,20 @@ jobs:
8998
key: ${{ runner.os }}-${{ matrix.target.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
9099
restore-keys: ${{ runner.os }}-${{ matrix.target.target }}-cargo-
91100

92-
- name: Create .sqlx directory if it doesn't exist
93-
run: mkdir -p backend/.sqlx
101+
- name: Cache SQLx metadata
102+
uses: actions/cache@v3
103+
with:
104+
path: backend/.sqlx
105+
key: ${{ runner.os }}-sqlx-${{ hashFiles('**/*.rs', '**/migrations/**') }}
106+
restore-keys: ${{ runner.os }}-sqlx-
107+
108+
- name: Install SQLx CLI
109+
run: cargo install sqlx-cli --no-default-features --features postgres
94110

95-
- name: Generate SQLx metadata
111+
- name: Prepare SQLx metadata
96112
run: |
113+
mkdir -p backend/.sqlx
97114
cd backend
98-
cargo install sqlx-cli --no-default-features --features postgres
99115
cargo sqlx prepare -- --tests
100116
env:
101117
DATABASE_URL: ${{ secrets.DATABASE_URL }}
@@ -111,11 +127,7 @@ jobs:
111127
run: |
112128
cd backend
113129
mkdir -p release
114-
if [ "${{ matrix.target.os }}" = "windows-latest" ]; then
115-
cp target/${{ matrix.target.target }}/release/${{ matrix.target.bin }} release/${{ matrix.target.asset_name }}
116-
else
117-
cp target/${{ matrix.target.target }}/release/${{ matrix.target.bin }} release/${{ matrix.target.asset_name }}
118-
fi
130+
cp target/${{ matrix.target.target }}/release/${{ matrix.target.bin }} release/${{ matrix.target.asset_name }}
119131
120132
- name: Upload binary as artifact
121133
uses: actions/upload-artifact@v4
@@ -140,7 +152,7 @@ jobs:
140152
- name: List downloaded artifacts (for debugging)
141153
run: ls -R artifacts
142154

143-
- name: Create Release
155+
- name: Create GitHub Release
144156
uses: softprops/action-gh-release@v1
145157
with:
146158
files: artifacts/**

0 commit comments

Comments
 (0)