Skip to content

Commit ecc5ca7

Browse files
committed
ci: improve test and deploy workflows
1 parent ad34278 commit ecc5ca7

2 files changed

Lines changed: 53 additions & 18 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,29 @@ on:
66
types: [completed]
77
branches: [master]
88

9+
permissions: {}
10+
911
jobs:
1012
deploy:
11-
if: github.event.workflow_run.conclusion == 'success'
13+
if: >-
14+
github.event.workflow_run.event == 'push' &&
15+
github.event.workflow_run.conclusion == 'success'
1216
runs-on: ubuntu-latest
17+
timeout-minutes: 10
1318
steps:
14-
- name: Set up SSH
19+
- name: Configure SSH
20+
env:
21+
SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
22+
SSH_KNOWN_HOSTS: ${{ secrets.DEPLOY_KNOWN_HOSTS }}
1523
run: |
16-
mkdir -p ~/.ssh
17-
echo "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/id_ed25519
24+
install -d -m 700 ~/.ssh
25+
printf '%s\n' "$SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519
1826
chmod 600 ~/.ssh/id_ed25519
19-
ssh-keyscan -H ${{ secrets.DEPLOY_HOST }} >> ~/.ssh/known_hosts 2>/dev/null
27+
printf '%s\n' "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
28+
chmod 600 ~/.ssh/known_hosts
2029
2130
- name: Deploy
22-
run: ssh ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }}
31+
env:
32+
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
33+
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
34+
run: ssh -o BatchMode=yes -o StrictHostKeyChecking=yes "$DEPLOY_USER@$DEPLOY_HOST"

.github/workflows/tests.yml

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,45 @@ on:
66
pull_request:
77
branches: [master]
88

9+
permissions:
10+
contents: read
11+
12+
concurrency:
13+
group: tests-${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
916
jobs:
1017
test:
1118
runs-on: ubuntu-latest
19+
timeout-minutes: 10
1220
steps:
13-
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
14-
- uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
15-
- run: uv python install 3.14
16-
- run: uv sync --dev
17-
- run: uv run pytest --tb=short -q
18-
21+
- name: Check out repository
22+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
23+
- name: Install uv
24+
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
25+
with:
26+
version: latest-known
27+
- name: Install Python
28+
run: uv python install 3.14
29+
- name: Install dependencies
30+
run: uv sync --locked --dev
31+
- name: Run tests
32+
run: uv run --no-sync pytest --tb=short -q
1933
lint:
2034
runs-on: ubuntu-latest
35+
timeout-minutes: 10
2136
steps:
22-
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
23-
- uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
24-
- run: uv python install 3.14
25-
- run: uv sync --dev
26-
- run: uv run ruff check .
27-
- run: uv run ruff format --check .
37+
- name: Check out repository
38+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
39+
- name: Install uv
40+
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
41+
with:
42+
version: latest-known
43+
- name: Install Python
44+
run: uv python install 3.14
45+
- name: Install dependencies
46+
run: uv sync --locked --dev
47+
- name: Run Ruff
48+
run: uv run --no-sync ruff check .
49+
- name: Check formatting
50+
run: uv run --no-sync ruff format --check .

0 commit comments

Comments
 (0)