Skip to content

Commit 3f9cfc5

Browse files
authored
Merge pull request #23 from Azure-Samples/revamp-validation
Revamp build validation
2 parents bb8c6ec + 89fd883 commit 3f9cfc5

File tree

3 files changed

+43
-53
lines changed

3 files changed

+43
-53
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
<!-- Verify that you have linted and formatted your Python code correctly -->
44

55
```bash
6-
pip install flake8
7-
flake8 --verbose <folder-name>/app.py
6+
pip install flake8 black
7+
```
8+
9+
```bash
10+
flake8 --verbose *.py
811

9-
pip install black
10-
black --verbose <folder-name>/app.py
12+
black --verbose --line-length 79 *.py
1113
```

.github/workflows/validate.yml

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,60 @@
11
name: Validate Python projects
22
on:
3+
push:
34
pull_request:
45
paths:
56
- '**.py'
67
branches:
78
- main
89
jobs:
10+
index:
11+
name: Generate matrix of project directories
12+
runs-on: ubuntu-latest
13+
outputs:
14+
projects: ${{ steps.set_output.outputs.matches }}
15+
steps:
16+
- name: Checkout source code
17+
uses: actions/checkout@v4
18+
- name: List directories
19+
run: find -name '*.py' -type 'f' -printf '%h\n' | uniq
20+
- name: Set output
21+
id: set_output
22+
run: echo "matches=$(find -name '*.py' -type 'f' -printf '%h\n' | uniq | jq --null-input --raw-input --compact-output --sort-keys '[inputs|select(length > 0)]')" >> $GITHUB_OUTPUT
923
validate:
1024
name: Validate Python project
25+
needs: index
1126
runs-on: ubuntu-latest
1227
container: python:3.7
1328
strategy:
1429
matrix:
15-
project-directory:
16-
- ./001-quickstart
17-
- ./002-quickstart-async
18-
- ./003-how-to
19-
- ./004-create-db
20-
- ./005-create-container
30+
project-directory: ${{ fromJson(needs.index.outputs.projects) }}
2131
defaults:
2232
run:
2333
working-directory: ${{ matrix.project-directory }}
2434
steps:
2535
- name: Checkout source code
26-
uses: actions/checkout@v2
27-
- name: Check Python version
36+
uses: actions/checkout@v4
37+
- name: Output Python version
2838
run: python --version
2939
- name: Install packages
3040
run: pip install black flake8
3141
- name: Lint with flake8
3242
run: flake8 --count --verbose *.py
3343
- name: Check format with black
34-
run: black --check --verbose --line-length 79 *.py
44+
run: black --check --verbose --line-length 79 *.py
45+
summarize:
46+
name: Summarize all validation jobs
47+
needs:
48+
- index
49+
- validate
50+
runs-on: ubuntu-latest
51+
if: ${{ always() }}
52+
steps:
53+
- name: Evaluate status of jobs
54+
if: >-
55+
${{
56+
contains(needs.*.result, 'failure')
57+
|| contains(needs.*.result, 'cancelled')
58+
|| contains(needs.*.result, 'skipped')
59+
}}
60+
run: exit 1

readme.md

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,9 @@
22

33
## Getting started
44

5-
This repo has a prebuilt development environment making it easy to get started.
5+
This repo has a [devcontainer](https://containers.dev) environment making it easy to get started.
66

7-
### Pull the repo
8-
9-
Open the repo in a [development container](https://containers.dev) using either Visual Studio Code or GitHub Codespaces.
10-
11-
- **Visual Studio Code**: Clone this repo to your local machine and open the folder using the [Dev containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers).
12-
13-
- **GitHub Codespaces**: Open this repo in the browser with a [GitHub codespace](https://docs.github.com/en/codespaces/overview).
7+
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/Azure-Samples/cosmos-db-nosql-python-samples?quickstart=1)
148

159
### Run the app
1610

@@ -30,26 +24,6 @@ pip install azure-cosmos
3024
python 001-quickstart/app.py
3125
```
3226

33-
The application should output a single JSON object.
34-
35-
```json
36-
{
37-
"id": "70b63682-b93a-4c77-aad2-65501347265f",
38-
"categoryId": "61dba35b-4f02-45c5-b648-c6badc0cbd79",
39-
"categoryName": "gear-surf-surfboards",
40-
"name": "Yamba Surfboard",
41-
"quantity": 12,
42-
"sale": false,
43-
"_rid": "yzN6AIfJxe0BAAAAAAAAAA==",
44-
"_self": "dbs/yzN6AA==/colls/yzN6AIfJxe0=/docs/yzN6AIfJxe0BAAAAAAAAAA==/",
45-
"_etag": "\"2a00ccd4-0000-0200-0000-63650e420000\"",
46-
"_attachments": "attachments/",
47-
"_ts": 16457527130
48-
}
49-
```
50-
51-
> **💡 TIP**: The fields assigned by Azure Cosmos DB (ex. `id`) will vary from this sample output.
52-
5327
### Validate any changes you make
5428

5529
If you change the code, run the linter and code formatter.
@@ -71,15 +45,3 @@ If you use a self-signed certificate to connect your Cosmos DB instance (Cosmos-
7145
```bash
7246
export REQUESTS_CA_BUNDLE='/etc/ssl/certs/emulatorcert.pem'
7347
```
74-
75-
## Samples
76-
77-
This project contains multiple samples used in [Azure Cosmos DB for NoSQL](https://learn.microsoft.com/azure/cosmos-db/nosql/) documentation.
78-
79-
| Sample | Documentation |
80-
| --- | --- |
81-
| [001-quickstart](001-quickstart/app.py) | [Quickstart: Azure Cosmos DB for NoSQL client library for Python](https://learn.microsoft.com/azure/cosmos-db/nosql/quickstart-python?tabs=azure-portal%2Clinux%2Csync) |
82-
| [002-quickstart-async](002-quickstart-async/app.py) | [Quickstart: Azure Cosmos DB for NoSQL client library for Python](https://learn.microsoft.com/azure/cosmos-db/nosql/quickstart-python?tabs=azure-portal%2Clinux%2Casync) |
83-
| [[003-how-to](003-how-to/app.py)] | [Get started with Azure Cosmos DB for NoSQL using Python](https://learn.microsoft.com/azure/cosmos-db/nosql/how-to-python-get-started) |
84-
| [[004-create-db](003-how-to/app.py)] | [Create a database in Azure Cosmos DB for NoSQL using Python](https://learn.microsoft.com/azure/cosmos-db/nosql/how-to-python-create-database) |
85-
| [[005-create-container](003-how-to/app.py)] | [Create a container in Azure Cosmos DB for NoSQL using Python](https://learn.microsoft.com/azure/cosmos-db/nosql/how-to-python-create-container) |

0 commit comments

Comments
 (0)