Skip to content

Commit e7f77a7

Browse files
committed
fix: add ci/cd
1 parent c17f476 commit e7f77a7

7 files changed

Lines changed: 439 additions & 0 deletions

File tree

.github/workflows/cd.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: CD
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- pyproject.toml
10+
11+
jobs:
12+
lint:
13+
uses: ./.github/workflows/lint.yml
14+
15+
test:
16+
uses: ./.github/workflows/test.yml
17+
18+
build:
19+
name: Build
20+
runs-on: ubuntu-latest
21+
22+
needs:
23+
- lint
24+
- test
25+
26+
if: ${{ github.repository == 'UiPath/uipath-python' }}
27+
permissions:
28+
contents: read
29+
actions: write
30+
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
35+
- name: Setup uv
36+
uses: astral-sh/setup-uv@v5
37+
with:
38+
enable-cache: true
39+
40+
- name: Setup Python
41+
uses: actions/setup-python@v5
42+
with:
43+
python-version-file: ".python-version"
44+
45+
- name: Install dependencies
46+
run: uv sync --all-extras
47+
48+
- name: Build
49+
run: uv build
50+
51+
- name: Upload artifacts
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: release-dists
55+
path: dist/
56+
57+
pypi-publish:
58+
name: Upload release to PyPI
59+
runs-on: ubuntu-latest
60+
environment: pypi
61+
62+
needs:
63+
- build
64+
permissions:
65+
contents: read
66+
id-token: write
67+
68+
steps:
69+
- name: Retrieve release distributions
70+
uses: actions/download-artifact@v4
71+
with:
72+
name: release-dists
73+
path: dist/
74+
75+
- name: Publish package distributions to PyPI
76+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/ci.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths-ignore:
8+
- pyproject.toml
9+
pull_request:
10+
branches:
11+
- main
12+
13+
jobs:
14+
commit-lint:
15+
if: ${{ github.event_name == 'pull_request' }}
16+
uses: ./.github/workflows/commitlint.yml
17+
18+
lint:
19+
uses: ./.github/workflows/lint.yml
20+
21+
test:
22+
uses: ./.github/workflows/test.yml

.github/workflows/commitlint.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Commit Lint
2+
3+
on:
4+
workflow_call
5+
6+
jobs:
7+
commitlint:
8+
name: Commit Lint
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Setup Node
20+
uses: actions/setup-node@v3
21+
with:
22+
node-version: 22
23+
24+
- name: Install Git
25+
run: |
26+
if ! command -v git &> /dev/null; then
27+
echo "Git is not installed. Installing..."
28+
sudo apt-get update
29+
sudo apt-get install -y git
30+
else
31+
echo "Git is already installed."
32+
fi
33+
34+
- name: Install commitlint
35+
run: |
36+
npm install conventional-changelog-conventionalcommits
37+
npm install commitlint@latest
38+
npm install @commitlint/config-conventional
39+
40+
- name: Configure
41+
run: |
42+
echo "export default { extends: ['@commitlint/config-conventional'] };" > commitlint.config.js
43+
44+
- name: Validate PR commits with commitlint
45+
run: |
46+
git fetch origin pull/${{ github.event.pull_request.number }}/head:pr_branch
47+
npx commitlint --from ${{ github.event.pull_request.base.sha }} --to pr_branch --verbose
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Integration testing
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
permissions:
10+
contents: read
11+
pull-requests: write
12+
actions: read
13+
14+
jobs:
15+
discover-testcases:
16+
runs-on: ubuntu-latest
17+
outputs:
18+
testcases: ${{ steps.discover.outputs.testcases }}
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Discover testcases
24+
id: discover
25+
run: |
26+
# Find all testcase folders (excluding common folders like README, etc.)
27+
testcase_dirs=$(find testcases -maxdepth 1 -type d -name "*-*" | sed 's|testcases/||' | sort)
28+
29+
echo "Found testcase directories:"
30+
echo "$testcase_dirs"
31+
32+
# Convert to JSON array for matrix
33+
testcases_json=$(echo "$testcase_dirs" | jq -R -s -c 'split("\n")[:-1]')
34+
echo "testcases=$testcases_json" >> $GITHUB_OUTPUT
35+
36+
integration-tests:
37+
needs: [discover-testcases]
38+
runs-on: ubuntu-latest
39+
container:
40+
image: ghcr.io/astral-sh/uv:python3.12-bookworm
41+
env:
42+
UIPATH_JOB_KEY: "3a03d5cb-fa21-4021-894d-a8e2eda0afe0"
43+
strategy:
44+
fail-fast: false
45+
matrix:
46+
testcase: ${{ fromJson(needs.discover-testcases.outputs.testcases) }}
47+
environment: [alpha, cloud]
48+
49+
name: "${{ matrix.testcase }} / ${{ matrix.environment }}"
50+
51+
steps:
52+
- name: Checkout code
53+
uses: actions/checkout@v4
54+
55+
- name: Install dependencies
56+
run: uv sync
57+
58+
- name: Run testcase
59+
env:
60+
CLIENT_ID: ${{ matrix.environment == 'alpha' && secrets.ALPHA_TEST_CLIENT_ID || secrets.CLOUD_TEST_CLIENT_ID }}
61+
CLIENT_SECRET: ${{ matrix.environment == 'alpha' && secrets.ALPHA_TEST_CLIENT_SECRET || secrets.CLOUD_TEST_CLIENT_SECRET }}
62+
BASE_URL: ${{ matrix.environment == 'alpha' && secrets.ALPHA_BASE_URL || secrets.CLOUD_BASE_URL }}
63+
USE_AZURE_CHAT: ${{ matrix.use_azure_chat }}
64+
working-directory: testcases/${{ matrix.testcase }}
65+
run: |
66+
# If any errors occur execution will stop with exit code
67+
set -e
68+
69+
echo "Running testcase: ${{ matrix.testcase }}"
70+
echo "Environment: ${{ matrix.environment }}"
71+
echo "Working directory: $(pwd)"
72+
73+
# Execute the testcase run script directly
74+
bash run.sh
75+
bash ../common/validate_output.sh
76+
77+
summarize-results:
78+
needs: [integration-tests]
79+
runs-on: ubuntu-latest
80+
if: always() # This ensures the job runs even if the tests fail
81+
steps:
82+
- name: Check integration tests status
83+
run: |
84+
if [[ "${{ needs.integration-tests.result }}" == "success" ]]; then
85+
echo "All integration tests passed"
86+
else
87+
echo "Some integration tests failed"
88+
exit 1
89+
fi

.github/workflows/lint.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Lint
2+
3+
on:
4+
workflow_call
5+
6+
jobs:
7+
lint:
8+
name: Lint
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Setup uv
18+
uses: astral-sh/setup-uv@v5
19+
with:
20+
enable-cache: true
21+
22+
- name: Setup Python
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version-file: ".python-version"
26+
27+
- name: Install dependencies
28+
run: uv sync --all-extras
29+
30+
- name: Check static types
31+
run: uv run mypy --config-file pyproject.toml .
32+
33+
- name: Check linting
34+
run: uv run ruff check .
35+
36+
- name: Check formatting
37+
run: uv run ruff format --check .
38+
39+

0 commit comments

Comments
 (0)