Skip to content

Commit 0c3e6fb

Browse files
committed
feat: add poetry support
1 parent b6d6cf0 commit 0c3e6fb

File tree

4 files changed

+2090
-244
lines changed

4 files changed

+2090
-244
lines changed

.github/workflows/ci.yml

Lines changed: 82 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -16,144 +16,104 @@ jobs:
1616
matrix:
1717
os: [ubuntu-latest, windows-latest, macos-latest]
1818
python-version: ["3.13"]
19-
include:
20-
# Test on additional Python versions on Ubuntu only
21-
- os: ubuntu-latest
22-
python-version: "3.13"
23-
24-
continue-on-error: ${{ matrix.experimental == true }}
2519

2620
steps:
27-
- uses: actions/checkout@v4
28-
29-
- name: Set up Python ${{ matrix.python-version }}
30-
uses: actions/setup-python@v5
31-
with:
32-
python-version: ${{ matrix.python-version }}
33-
cache: 'pip'
34-
cache-dependency-path: |
35-
pyproject.toml
36-
37-
- name: Install dependencies
38-
run: |
39-
python -m pip install --upgrade pip
40-
pip cache purge
41-
pip install --no-cache-dir -e ".[dev]"
42-
43-
- name: Run tests with pytest
44-
run: |
45-
pytest -v --cov=thegraph_token_api --cov-report=term-missing --cov-report=xml --cov-report=html
46-
47-
- name: Upload coverage to Codecov
48-
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.13'
49-
uses: codecov/codecov-action@v5
50-
with:
51-
file: ./coverage.xml
52-
flags: unittests
53-
name: codecov-umbrella
54-
fail_ci_if_error: false
55-
token: ${{ secrets.CODECOV_TOKEN }}
56-
57-
- name: Upload coverage reports
58-
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.13'
59-
uses: actions/upload-artifact@v4
60-
with:
61-
name: coverage-report
62-
path: htmlcov/
63-
64-
- name: Check coverage threshold
65-
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.13'
66-
run: |
67-
coverage report --fail-under=90
21+
- uses: actions/checkout@v4
22+
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
28+
- name: Install Poetry via pip
29+
run: |
30+
python -m pip install --upgrade pip poetry
31+
32+
- name: Install dependencies
33+
run: poetry install --no-interaction --with dev --no-root
34+
35+
- name: Run tests with pytest
36+
run: poetry run pytest -v --cov=thegraph_token_api --cov-report=term-missing --cov-report=xml --cov-report=html
37+
shell: bash
38+
39+
- name: Upload coverage to Codecov
40+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.13'
41+
uses: codecov/codecov-action@v5
42+
with:
43+
file: ./coverage.xml
44+
flags: unittests
45+
name: codecov-umbrella
46+
fail_ci_if_error: false
47+
token: ${{ secrets.CODECOV_TOKEN }}
48+
49+
- name: Upload coverage reports
50+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.13'
51+
uses: actions/upload-artifact@v4
52+
with:
53+
name: coverage-report
54+
path: htmlcov/
55+
56+
- name: Check coverage threshold
57+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.13'
58+
run: poetry run coverage report --fail-under=90
6859

6960
lint:
7061
runs-on: ubuntu-latest
7162
steps:
72-
- uses: actions/checkout@v4
63+
- uses: actions/checkout@v4
7364

74-
- name: Set up Python
75-
uses: actions/setup-python@v5
76-
with:
77-
python-version: "3.13"
78-
cache: 'pip'
65+
- name: Set up Python
66+
uses: actions/setup-python@v5
67+
with:
68+
python-version: "3.13"
7969

80-
- name: Install dependencies
81-
run: |
82-
python -m pip install --upgrade pip
83-
pip cache purge
84-
pip install --no-cache-dir -e ".[dev]"
70+
- name: Install Poetry via pip
71+
run: |
72+
python -m pip install --upgrade pip poetry
8573
86-
- name: Run ruff linter
87-
run: |
88-
ruff check --output-format=github .
74+
- name: Install dependencies
75+
run: poetry install --no-interaction --with dev --no-root
8976

90-
- name: Run ruff formatter
91-
run: |
92-
ruff format --check .
77+
- name: Run ruff linter
78+
run: poetry run ruff check --output-format=github .
9379

94-
- name: Run mypy
95-
run: |
96-
mypy src/thegraph_token_api --ignore-missing-imports
80+
- name: Run ruff formatter
81+
run: poetry run ruff format --check .
9782

98-
- name: Run bandit security scan
99-
run: |
100-
bandit -r src/ -f txt
83+
- name: Run mypy
84+
run: poetry run mypy src/thegraph_token_api --ignore-missing-imports
10185

102-
- name: Run safety dependency check
103-
run: |
104-
safety check
86+
- name: Run bandit security scan
87+
run: poetry run bandit -r src/ -f txt
10588

106-
security:
107-
runs-on: ubuntu-latest
108-
if: github.event_name != 'workflow_call'
109-
permissions:
110-
security-events: write
111-
contents: read
112-
steps:
113-
- uses: actions/checkout@v4
114-
115-
- name: Run Trivy vulnerability scanner
116-
uses: aquasecurity/trivy-action@master
117-
with:
118-
scan-type: 'fs'
119-
scan-ref: '.'
120-
format: 'sarif'
121-
output: 'trivy-results.sarif'
122-
severity: 'CRITICAL,HIGH'
123-
124-
- name: Upload Trivy scan results to GitHub Security tab
125-
uses: github/codeql-action/upload-sarif@v3
126-
if: always()
127-
with:
128-
sarif_file: 'trivy-results.sarif'
89+
- name: Run safety dependency check
90+
run: poetry run safety check
12991

13092
build:
13193
runs-on: ubuntu-latest
13294
needs: [test]
13395
steps:
134-
- uses: actions/checkout@v4
135-
136-
- name: Set up Python
137-
uses: actions/setup-python@v5
138-
with:
139-
python-version: "3.13"
140-
cache: 'pip'
141-
142-
- name: Install build dependencies
143-
run: |
144-
python -m pip install --upgrade pip
145-
pip install build
146-
147-
- name: Build package
148-
run: |
149-
python -m build
150-
151-
- name: Check dist contents
152-
run: |
153-
ls -la dist/
154-
155-
- name: Upload artifacts
156-
uses: actions/upload-artifact@v4
157-
with:
158-
name: dist-packages
159-
path: dist/
96+
- uses: actions/checkout@v4
97+
98+
- name: Set up Python
99+
uses: actions/setup-python@v5
100+
with:
101+
python-version: "3.13"
102+
103+
- name: Install Poetry via pip
104+
run: |
105+
python -m pip install --upgrade pip poetry
106+
107+
- name: Install build dependencies & build
108+
run: |
109+
poetry install --no-interaction --no-root
110+
poetry build
111+
112+
- name: Check dist contents
113+
run: ls -la dist/
114+
115+
- name: Upload artifacts
116+
uses: actions/upload-artifact@v4
117+
with:
118+
name: dist-packages
119+
path: dist/

.github/workflows/security.yml

Lines changed: 52 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,31 @@ jobs:
2222
matrix:
2323
language: ['python']
2424
steps:
25-
- name: Checkout repository
26-
uses: actions/checkout@v4
25+
- uses: actions/checkout@v4
2726

28-
- name: Initialize CodeQL
29-
uses: github/codeql-action/init@v3
30-
with:
31-
languages: ${{ matrix.language }}
32-
queries: +security-and-quality
27+
- name: Set up Python
28+
uses: actions/setup-python@v5
29+
with:
30+
python-version: '3.13'
3331

34-
- name: Set up Python
35-
uses: actions/setup-python@v5
36-
with:
37-
python-version: '3.13'
32+
- name: Install Poetry via pip
33+
run: |
34+
python -m pip install --upgrade pip poetry
3835
39-
- name: Install dependencies
40-
run: |
41-
python -m pip install --upgrade pip
42-
pip install -e .[dev]
36+
- name: Install dependencies (no root)
37+
run: |
38+
poetry install --no-interaction --with dev --no-root
4339
44-
- name: Perform CodeQL Analysis
45-
uses: github/codeql-action/analyze@v3
46-
with:
47-
category: "/language:${{matrix.language}}"
40+
- name: Initialize CodeQL
41+
uses: github/codeql-action/init@v3
42+
with:
43+
languages: ${{ matrix.language }}
44+
queries: +security-and-quality
45+
46+
- name: Perform CodeQL Analysis
47+
uses: github/codeql-action/analyze@v3
48+
with:
49+
category: "/language:${{matrix.language}}"
4850

4951
security:
5052
name: Security Scanning
@@ -53,37 +55,40 @@ jobs:
5355
security-events: write
5456
contents: read
5557
steps:
56-
- uses: actions/checkout@v4
58+
- uses: actions/checkout@v4
59+
60+
- name: Set up Python
61+
uses: actions/setup-python@v5
62+
with:
63+
python-version: '3.13'
5764

58-
- name: Set up Python
59-
uses: actions/setup-python@v5
60-
with:
61-
python-version: '3.13'
65+
- name: Install Poetry via pip
66+
run: |
67+
python -m pip install --upgrade pip poetry
6268
63-
- name: Install dependencies
64-
run: |
65-
python -m pip install --upgrade pip
66-
pip install -e .[dev]
69+
- name: Install dependencies (no root)
70+
run: |
71+
poetry install --no-interaction --with dev --no-root
6772
68-
- name: Run Safety check
69-
run: |
70-
safety check --json --output safety-results.json || true
73+
- name: Run Safety check
74+
run: |
75+
poetry run safety check --json --output safety-results.json || true
7176
72-
- name: Run Bandit security scan
73-
run: |
74-
bandit -r src/ -f json -o bandit-results.json || true
77+
- name: Run Bandit security scan
78+
run: |
79+
poetry run bandit -r src/ -f json -o bandit-results.json || true
7580
76-
- name: Run Trivy vulnerability scanner
77-
uses: aquasecurity/trivy-action@master
78-
with:
79-
scan-type: 'fs'
80-
scan-ref: '.'
81-
format: 'sarif'
82-
output: 'trivy-results.sarif'
83-
severity: 'CRITICAL,HIGH'
81+
- name: Run Trivy vulnerability scanner
82+
uses: aquasecurity/trivy-action@master
83+
with:
84+
scan-type: 'fs'
85+
scan-ref: '.'
86+
format: 'sarif'
87+
output: 'trivy-results.sarif'
88+
severity: 'CRITICAL,HIGH'
8489

85-
- name: Upload Trivy scan results to GitHub Security tab
86-
uses: github/codeql-action/upload-sarif@v3
87-
if: always()
88-
with:
89-
sarif_file: 'trivy-results.sarif'
90+
- name: Upload Trivy scan results to GitHub Security tab
91+
uses: github/codeql-action/upload-sarif@v3
92+
if: always()
93+
with:
94+
sarif_file: 'trivy-results.sarif'

0 commit comments

Comments
 (0)