Skip to content

Commit 802655b

Browse files
committed
More workflows
1 parent 082c94d commit 802655b

File tree

9 files changed

+105
-70
lines changed

9 files changed

+105
-70
lines changed

.devcontainer/devcontainer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
22
// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.0/containers/python-3
33
{
4-
"name": "RAG on database",
4+
"name": "rag-postgres-openai-python",
55
"dockerComposeFile": "docker-compose.yaml",
66
"service": "app",
77
"workspaceFolder": "/workspace",

.github/workflows/tests.yaml renamed to .github/workflows/app-tests.yaml

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Python check
1+
name: App Tests
22

33
on:
44
push:
@@ -33,4 +33,11 @@ jobs:
3333
architecture: x64
3434
- name: Install dependencies
3535
run: |
36-
python3 -m pip install -e src
36+
python -m pip install -r requirements-dev.txt
37+
- name: Install app as editable app
38+
run: |
39+
python -m pip install -e src
40+
- name: Setup local database with seed data
41+
cp .env.sample .env
42+
python ./src/fastapi_app/setup_postgres_database.py
43+
python ./src/fastapi_app/setup_postgres_seeddata.py

.github/workflows/bicep-audit.yaml

-34
This file was deleted.

.github/workflows/bicep-validation.yaml renamed to .github/workflows/bicep-security-scan.yaml

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Validate AZD template
1+
name: Bicep Security Scan
22
on:
33
push:
44
branches: [ main ]
@@ -10,7 +10,6 @@ on:
1010
- "infra/**"
1111
workflow_dispatch:
1212

13-
1413
jobs:
1514
build:
1615
runs-on: ubuntu-latest
@@ -21,19 +20,19 @@ jobs:
2120
uses: actions/checkout@v4
2221

2322
- name: Build Bicep for linting
24-
uses: azure/CLI@v1
23+
uses: azure/CLI@v2
2524
with:
2625
inlineScript: az config set bicep.use_binary_from_path=false && az bicep build -f infra/main.bicep --stdout
2726

2827
- name: Run Microsoft Security DevOps Analysis
29-
uses: microsoft/security-devops-action@v1
28+
uses: microsoft/security-devops-action@preview
3029
id: msdo
3130
continue-on-error: true
3231
with:
3332
tools: templateanalyzer
3433

3534
- name: Upload alerts to Security tab
3635
uses: github/codeql-action/upload-sarif@v3
37-
if: github.repository == 'Azure-Samples/langfuse-on-azure'
36+
if: github.repository == 'Azure-Samples/azure-search-openai-demo'
3837
with:
3938
sarif_file: ${{ steps.msdo.outputs.sarifFile }}
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Python code quality
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Set up Python 3
15+
uses: actions/setup-python@v5
16+
with:
17+
python-version: "3.12"
18+
- name: Install dependencies
19+
run: |
20+
python -m pip install --upgrade pip
21+
pip install -r requirements-dev.txt
22+
- name: Lint with ruff
23+
run: ruff .
24+
- name: Check formatting with black
25+
run: black . --check --verbose

CONTRIBUTING.md

+54-14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Contributing to [project-title]
1+
# Contributing
22

33
This project welcomes contributions and suggestions. Most contributions require you to agree to a
44
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
@@ -15,7 +15,9 @@ contact [[email protected]](mailto:[email protected]) with any additio
1515
- [Code of Conduct](#coc)
1616
- [Issues and Bugs](#issue)
1717
- [Feature Requests](#feature)
18-
- [Submission Guidelines](#submit)
18+
- [Submitting a PR](#submit-pr)
19+
- [Running Tests](#tests)
20+
- [Code Style](#style)
1921

2022
## <a name="coc"></a> Code of Conduct
2123
Help us keep this project open and inclusive. Please read and follow our [Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
@@ -51,26 +53,64 @@ chances of your issue being dealt with quickly:
5153
* **Suggest a Fix** - if you can't fix the bug yourself, perhaps you can point to what might be
5254
causing the problem (line of code or commit)
5355

54-
You can file new issues by providing the above information at the corresponding repository's issues link: https://github.com/Azure-Samples/rag-postgres-openai-python/issues/new].
56+
You can file new issues by providing the above information at the corresponding repository's issues link: https://github.com/Azure-samples/rag-postgres-openai-python/issues/new].
5557

5658
### <a name="submit-pr"></a> Submitting a Pull Request (PR)
5759
Before you submit your Pull Request (PR) consider the following guidelines:
5860

59-
* Search the repository (https://github.com/Azure-Samples/rag-postgres-openai-python/pulls) for an open or closed PR
61+
* Search the repository (https://github.com/Azure-samples/rag-postgres-openai-python/pulls) for an open or closed PR
6062
that relates to your submission. You don't want to duplicate effort.
61-
6263
* Make your changes in a new git fork
64+
* Follow [Code style conventions](#style)
65+
* [Run the tests](#tests) (and write new ones, if needed)
6366
* Commit your changes using a descriptive commit message
6467
* Push your fork to GitHub
65-
* In GitHub, create a pull request
66-
* If we suggest changes then:
67-
* Make the required updates.
68-
* Rebase your fork and force push to your GitHub repository (this will update your Pull Request):
68+
* In GitHub, create a pull request to the `main` branch of the repository
69+
* Ask a maintainer to review your PR and address any comments they might have
70+
71+
## <a name="tests"></a> Setting up the development environment
72+
73+
Install the development dependencies:
74+
75+
```
76+
python3 -m pip install -r requirements-dev.txt
77+
```
78+
79+
Install the pre-commit hooks:
80+
81+
```
82+
pre-commit install
83+
```
84+
85+
Compile the JavaScript:
86+
87+
```
88+
( cd ./app/frontend ; npm install ; npm run build )
89+
```
90+
91+
## <a name="style"></a> Code Style
92+
93+
This codebase includes several languages: TypeScript, Python, Bicep, Powershell, and Bash.
94+
Code should follow the standard conventions of each language.
95+
96+
For Python, you can enforce the conventions using `ruff` and `black`.
97+
98+
Install the development dependencies:
99+
100+
```
101+
python3 -m pip install -r requirements-dev.txt
102+
```
103+
104+
Run `ruff` to lint a file:
105+
106+
```
107+
python3 -m ruff <path-to-file>
108+
```
69109

70-
```shell
71-
git rebase master -i
72-
git push -f
73-
```
110+
Run `black` to format a file:
74111

75-
That's it! Thank you for your contribution!
112+
```
113+
python3 -m black <path-to-file>
114+
```
76115

116+
If you followed the steps above to install the pre-commit hooks, then you can just wait for those hooks to run `ruff` and `black` for you.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ You can run this template virtually by using GitHub Codespaces. The button will
4242
3. Sign in to your Azure account:
4343

4444
```shell
45-
azd auth login --use-device-code
45+
azd auth login
4646
```
4747

4848
4. Provision the resources and deploy the code:

infra/main.bicep

+9-10
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@ module web 'web.bicep' = {
246246
}
247247
}
248248

249-
250249
resource openAiResourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' existing =
251250
if (!empty(openAiResourceGroupName)) {
252251
name: !empty(openAiResourceGroupName) ? openAiResourceGroupName : resourceGroup.name
@@ -293,15 +292,16 @@ module openAi 'core/ai/cognitiveservices.bicep' = {
293292
}
294293

295294
// USER ROLES
296-
module openAiRoleUser 'core/security/role.bicep' = if (empty(runningOnGh)) {
297-
scope: openAiResourceGroup
298-
name: 'openai-role-user'
299-
params: {
300-
principalId: principalId
301-
roleDefinitionId: '5e0bd9bd-7b93-4f28-af87-19fc36ad61bd'
302-
principalType: 'User'
295+
module openAiRoleUser 'core/security/role.bicep' =
296+
if (empty(runningOnGh)) {
297+
scope: openAiResourceGroup
298+
name: 'openai-role-user'
299+
params: {
300+
principalId: principalId
301+
roleDefinitionId: '5e0bd9bd-7b93-4f28-af87-19fc36ad61bd'
302+
principalType: 'User'
303+
}
303304
}
304-
}
305305

306306
// Backend roles
307307
module openAiRoleBackend 'core/security/role.bicep' = {
@@ -314,7 +314,6 @@ module openAiRoleBackend 'core/security/role.bicep' = {
314314
}
315315
}
316316

317-
318317
output AZURE_LOCATION string = location
319318
output APPLICATIONINSIGHTS_NAME string = monitoring.outputs.applicationInsightsName
320319

infra/web.bicep

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@ param identityName string
99
param serviceName string = 'web'
1010
param environmentVariables array = []
1111

12-
1312
resource webIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
1413
name: identityName
1514
location: location
1615
}
1716

18-
1917
module app 'core/host/container-app-upsert.bicep' = {
2018
name: '${serviceName}-container-app-module'
2119
params: {
@@ -26,7 +24,8 @@ module app 'core/host/container-app-upsert.bicep' = {
2624
exists: exists
2725
containerAppsEnvironmentName: containerAppsEnvironmentName
2826
containerRegistryName: containerRegistryName
29-
env: union(environmentVariables,
27+
env: union(
28+
environmentVariables,
3029
[
3130
{
3231
name: 'APP_IDENTITY_ID'

0 commit comments

Comments
 (0)