Repository navigation
83 lines (67 loc) · 2.36 KB
/
Copy pathpython-tests.yml
File metadata and controls
83 lines (67 loc) · 2.36 KB
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
name: Python Unit Tests
on:
push:
branches: [master, develop]
pull_request:
branches: [master, develop]
types: [opened, synchronize, reopened]
schedule:
- cron: '20 4 * * *' # 04:20 UTC
concurrency:
group: ci-${{ github.event_name == 'schedule' && 'schedule' || github.ref_name }}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest
if: ${{ !(github.event_name == 'push' && contains(github.event.head_commit.message, '[skip ci]')) }}
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
steps:
- uses: actions/checkout@v6
- name: Install uv and set up Python ${{ matrix.python-version }}
uses: astral-sh/setup-uv@v8.0.0
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- name: Install LFTP
run: sudo apt-get update && sudo apt-get install -y lftp
- name: Install dependencies
run: uv sync --extra full
- name: Lint with Ruff
run: uv run ruff check .
- name: Create temporary SSH key
run: |
ssh-keygen -t rsa -b 4096 -f /tmp/temp_sftp_key -q -N ""
eval $(ssh-agent -s)
mkdir -p /tmp
ssh-add /tmp/temp_sftp_key
echo "SSH_AUTH_SOCK=$SSH_AUTH_SOCK" >> $GITHUB_ENV
- name: Start Docker SFTP Service
run: |
mkdir -p /tmp/upload
chmod ugo+rwx /tmp/upload
sudo docker run --name mock_sftp_server -p 0.0.0.0:2222:22 -d \
-v /tmp/temp_sftp_key.pub:/home/foo/.ssh/keys/temp_sftp_key.pub:ro \
-v /tmp/upload:/home/foo/upload \
atmoz/sftp foo::1001
- name: Add SSH key & Wait for Server
run: |
mkdir -p ~/.ssh
for i in {1..10}; do
ssh-keyscan -p 2222 -H 0.0.0.0 >> ~/.ssh/known_hosts && break
echo "Waiting for SFTP server to be ready..."
sleep 1
done
- name: Test LFTP connection
run: lftp -e "open -u foo, -p 2222 sftp://0.0.0.0; ls; bye"
- name: Run tests with coverage
run: uv run pytest --cov=src/pyremotedata --cov-report=xml --cov-report=term tests/
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v6
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: asgersvenning/pyremotedata
- name: Print Docker SFTP Server Logs
if: always()
run: sudo docker logs mock_sftp_server