Skip to content

Commit 2670d80

Browse files
authored
Split test workflow into PR and main branch push (#59)
* Split test workflow into PR and main branch push * Clean up test workflows
1 parent 18efeaa commit 2670d80

2 files changed

Lines changed: 74 additions & 68 deletions

File tree

.github/workflows/test-pr.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Run tests on Git-Mastery (PR)
2+
3+
on:
4+
pull_request_target:
5+
6+
permissions:
7+
contents: read
8+
pull-requests: read
9+
10+
jobs:
11+
test-e2e-pr:
12+
name: E2E Tests (${{ matrix.os }})
13+
if: github.repository == 'git-mastery/app'
14+
# Require manual approval before secrets are exposed to untrusted PR code
15+
environment: e2e-test
16+
runs-on: ${{ matrix.os }}
17+
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
os: [ubuntu-latest, macos-latest, windows-latest]
22+
python-version: ["3.13"]
23+
24+
steps:
25+
- name: Validate GH_PAT secret
26+
shell: bash
27+
env:
28+
GH_PAT: ${{ secrets.GH_PAT }}
29+
run: |
30+
if [ -z "$GH_PAT" ]; then
31+
echo "GH_PAT secret is required to run E2E tests."
32+
exit 1
33+
fi
34+
35+
- name: Checkout
36+
uses: actions/checkout@v4
37+
with:
38+
# Explicitly check out the PR branch so we build and test the submitted code
39+
# pull_request_target checks out the base branch by default
40+
repository: ${{ github.event.pull_request.head.repo.full_name }}
41+
ref: ${{ github.event.pull_request.head.sha }}
42+
43+
- name: Set up Python ${{ matrix.python-version }}
44+
uses: actions/setup-python@v5
45+
with:
46+
python-version: ${{ matrix.python-version }}
47+
48+
- name: Install dependencies
49+
run: |
50+
python -m pip install --upgrade pip
51+
pip install -r requirements.txt
52+
53+
- name: Build binary
54+
run: |
55+
pyinstaller --onefile main.py --name gitmastery
56+
57+
- name: Set binary path (Unix)
58+
if: runner.os != 'Windows'
59+
run: echo "GITMASTERY_BINARY=${{ github.workspace }}/dist/gitmastery" >> $GITHUB_ENV
60+
61+
- name: Set binary path (Windows)
62+
if: runner.os == 'Windows'
63+
run: echo "GITMASTERY_BINARY=${{ github.workspace }}/dist/gitmastery.exe" >> $env:GITHUB_ENV
64+
65+
- name: Configure Git
66+
run: |
67+
git config --global user.name "github-actions[bot]"
68+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
69+
70+
- name: Run E2E tests
71+
env:
72+
GH_TOKEN: ${{ secrets.GH_PAT }}
73+
run: |
74+
python -m pytest tests/e2e/ -v

.github/workflows/test.yml

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,17 @@
11
name: Run tests on Git-Mastery
22

33
on:
4-
pull_request_target:
54
workflow_dispatch:
65
push:
76
branches:
87
- main
98

109
permissions:
1110
contents: read
12-
pull-requests: read
1311

1412
jobs:
15-
test-e2e-pr:
16-
name: E2E Tests (${{ matrix.os }})
17-
if: github.event_name == 'pull_request_target'
18-
# Require manual approval before secrets are exposed to untrusted PR code
19-
environment: e2e-test
20-
runs-on: ${{ matrix.os }}
21-
22-
strategy:
23-
fail-fast: false
24-
matrix:
25-
os: [ubuntu-latest, macos-latest, windows-latest]
26-
python-version: ["3.13"]
27-
28-
steps:
29-
- name: Validate GH_PAT secret
30-
shell: bash
31-
env:
32-
GH_PAT: ${{ secrets.GH_PAT }}
33-
run: |
34-
if [ -z "$GH_PAT" ]; then
35-
echo "GH_PAT secret is required to run E2E tests."
36-
exit 1
37-
fi
38-
39-
- name: Checkout
40-
uses: actions/checkout@v4
41-
with:
42-
# Explicitly check out the PR branch so we build and test the submitted code
43-
# pull_request_target checks out the base branch by default
44-
repository: ${{ github.event.pull_request.head.repo.full_name }}
45-
ref: ${{ github.event.pull_request.head.sha }}
46-
47-
- name: Set up Python ${{ matrix.python-version }}
48-
uses: actions/setup-python@v5
49-
with:
50-
python-version: ${{ matrix.python-version }}
51-
52-
- name: Install dependencies
53-
run: |
54-
python -m pip install --upgrade pip
55-
pip install -r requirements.txt
56-
57-
- name: Build binary
58-
run: |
59-
pyinstaller --onefile main.py --name gitmastery
60-
61-
- name: Set binary path (Unix)
62-
if: runner.os != 'Windows'
63-
run: echo "GITMASTERY_BINARY=${{ github.workspace }}/dist/gitmastery" >> $GITHUB_ENV
64-
65-
- name: Set binary path (Windows)
66-
if: runner.os == 'Windows'
67-
run: echo "GITMASTERY_BINARY=${{ github.workspace }}/dist/gitmastery.exe" >> $env:GITHUB_ENV
68-
69-
- name: Configure Git
70-
run: |
71-
git config --global user.name "github-actions[bot]"
72-
git config --global user.email "github-actions[bot]@users.noreply.github.com"
73-
74-
- name: Run E2E tests
75-
env:
76-
GH_TOKEN: ${{ secrets.GH_PAT }}
77-
run: |
78-
python -m pytest tests/e2e/ -v
79-
8013
test-e2e:
8114
name: E2E Tests (${{ matrix.os }})
82-
if: github.event_name != 'pull_request_target' && github.repository == 'git-mastery/app'
8315
runs-on: ${{ matrix.os }}
8416

8517
strategy:

0 commit comments

Comments
 (0)