-
Notifications
You must be signed in to change notification settings - Fork 0
215 lines (181 loc) · 6.39 KB
/
workflow.yml
File metadata and controls
215 lines (181 loc) · 6.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
name: CI/CD Pipeline
on:
push:
branches:
- master
release:
types:
- published
permissions:
contents: write
jobs:
integration-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
# Backend Setup and Tests
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
cache: 'pip'
cache-dependency-path: backend/requirements.txt
- name: Install dependencies
working-directory: backend
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Create .env file for backend
working-directory: backend
run: |
echo "DATABASE_URL=sqlite:///./db/todo.db" >> .env
echo "SECRET_KEY=f0520f3a5a8834b9ab2dbbc57d5988b8db20db8bfbe8e64fa1abc3e22141e23c" >> .env
echo "ALGORITHM=HS256" >> .env
echo "ACCESS_TOKEN_EXPIRE_MINUTES=30" >> .env
echo "REFRESH_TOKEN_EXPIRE_DAYS=7" >> .env
- name: Create test SQLite DB file
working-directory: backend
run:
mkdir db
touch db/todo_test.db
- name: Run tests
working-directory: backend
run:
pytest
- name: Start backend server for integration tests on frontend
working-directory: backend
run:
nohup uvicorn main:app --host 0.0.0.0 --port 8000 &
continue-on-error: false # Without Backend server Frontend Tests will fail
# Frontend Setup and Tests
- name: Cache Flutter dependencies
uses: actions/cache@v4
with:
path: ~/.pub-cache
key: ${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.lock') }}
restore-keys: |
${{ runner.os }}-flutter-
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
cache: true
channel: stable
- run: flutter --version
working-directory: frontend
- name: Install dependencies
working-directory: frontend
run: |
sudo apt-get update
sudo apt-get install -y ninja-build cmake libgtk-3-dev libblkid-dev liblzma-dev
flutter pub get
flutter create . --platforms=linux
- name: Run auth integration test
uses: gabrielbb/xvfb-action@v1
with:
working-directory: frontend
run:
flutter test integration_test/auth_integration_test.dart -d linux -r github
- name: Run tasks integration test
uses: gabrielbb/xvfb-action@v1
with:
working-directory: frontend
run:
flutter test integration_test/tasks_integration_test.dart -d linux -r github
build:
needs: integration-tests
defaults:
run:
working-directory: frontend
strategy:
matrix:
os: [ubuntu-latest, windows-latest] # Указываем разные хосты
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cache Flutter dependencies
uses: actions/cache@v4
with:
path: ~/.pub-cache
key: ${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.lock') }}
restore-keys: |
${{ runner.os }}-flutter-
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
cache: true
channel: stable
- name: Install dependencies on Linux
if: matrix.os == 'ubuntu-latest'
run: |
flutter pub get
sudo apt-get update
sudo apt-get install -y ninja-build cmake libgtk-3-dev libblkid-dev liblzma-dev
flutter create . --platforms=linux
flutter config --enable-linux-desktop
- name: Instal dependencies on Windows
if: matrix.os == 'windows-latest'
run: |
flutter pub get
flutter create . --platforms=windows
flutter config --enable-windows-desktop
- name: Build App for Windows
if: matrix.os == 'windows-latest'
run: flutter build windows --dart-define=BASE_API_URL=https://taskflow-112i.onrender.com/api/ --release
- name: Build App for Linux
if: matrix.os == 'ubuntu-latest'
run: flutter build linux --dart-define=BASE_API_URL=https://taskflow-112i.onrender.com/api/ --release
# Prepare release assets
- name: Prepare release assets for Windows
if: matrix.os == 'windows-latest'
shell: pwsh # Для Windows
run: |
mkdir ${{ github.workspace }}\release-assets\windows
Copy-Item -Path build\windows\x64\runner\Release\* -Destination ${{ github.workspace }}\release-assets\windows -Recurse
Compress-Archive -Path build\windows\x64\runner\Release\* -DestinationPath ${{ github.workspace }}\release-assets\windows\frontend-windows.zip
Get-ChildItem -Recurse -Force -Path ${{ github.workspace }}\release-assets\windows
- name: Prepare release assets for Linux
if: matrix.os == 'ubuntu-latest'
shell: bash
run: |
mkdir -p ${{ github.workspace }}/release-assets/linux
cp -r build/linux/x64/release/bundle/* ${{ github.workspace }}/release-assets/linux/
tar -czf ${{ github.workspace }}/release-assets/linux/frontend-linux.tar.gz -C build/linux/x64/release/bundle .
ls -R ${{ github.workspace }}/release-assets/linux
# Upload release artifacts windows
- name: Upload Release Assets fro
if: matrix.os == 'windows-latest'
uses: actions/upload-artifact@v4
with:
name: windows-artifacts
path: ${{ github.workspace }}/release-assets/windows/frontend-windows.zip
- name: Upload Linux Artifacts
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: linux-artifacts
path: ${{ github.workspace }}/release-assets/linux/frontend-linux.tar.gz
release-upload:
runs-on: ubuntu-latest
needs: build
steps:
- name: Download Linux Artifacts
uses: actions/download-artifact@v4
with:
name: linux-artifacts
path: release-files/linux
- name: Download Windows Artifacts
uses: actions/download-artifact@v4
with:
name: windows-artifacts
path: release-files/windows
- name: Create GitHub Release
uses: softprops/action-gh-release@v2.2.1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
release-files/linux/frontend-linux.tar.gz
release-files/windows/frontend-windows.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}