-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (86 loc) · 3.27 KB
/
build-workflow.yml
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
name: Test and Report
on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies on ${{ matrix.python-version }}
run: |
python -m pip install --upgrade pip
python -m pip install pdm
pdm sync --dev
- name: Test reports on ${{ matrix.python-version }}
run: pdm reports
- name: Build on ${{ matrix.python-version }}
run: pdm build
reports:
permissions:
contents: write
pull-requests: write
issues: write
runs-on: ubuntu-latest
environment: test
strategy:
matrix:
python-version: ["3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies on ${{ matrix.python-version }}
run: |
python -m pip install --upgrade pip
python -m pip install pdm
pdm sync --dev
- name: Test reports on ${{ matrix.python-version }}
run: pdm reports
- name: Update PR with reports
uses: actions/github-script@v7
if: ${{ github.event_name == 'pull_request' }}
with:
# language=javascript
script: |
const fs = require('fs')
const test_content = fs.readFileSync('reports/junit/junit.xml', 'utf8')
const coverage_content = fs.readFileSync('reports/coverage/coverage.xml', 'utf8')
const flake8_content = fs.readFileSync('reports/flake8/stats.txt', 'utf8')
const test_details = `<details><summary>Test Report</summary>\n\n\`\`\`xml\n${test_content}\n\`\`\`\n\n</details>`
const coverage_details = `<details><summary>Coverage Report</summary>\n\n\`\`\`xml\n${coverage_content}\n\`\`\`\n\n</details>`
const flake8_details = `<details><summary>Flake8 Report</summary>\n\n\`\`\`\n${flake8_content}\n\`\`\`\n\n</details>`
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `## Reports:\n${test_details}\n${coverage_details}\n${flake8_details}`
})
- name: Build on ${{ matrix.python-version }}
run: pdm build
- name: Style
if: ${{ !cancelled() }}
run: pdm style
- name: Badges
if: ${{ !cancelled() && github.event_name == 'pull_request' }}
run: |
git config --global user.name 'Auto'
git config --global user.email '[email protected]'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
git fetch origin "${GITHUB_HEAD_REF}"
git checkout "${GITHUB_HEAD_REF}"
pdm badges-only
git commit -am "Update Badges"
git push