Skip to content

Commit edb6c5d

Browse files
authored
Add reusable action (#446)
1 parent 0fca338 commit edb6c5d

19 files changed

+125
-159
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: 'prepare to build a package'
2+
description: 'Downloads and unpacks snap7 archive. Copies the required files. Updates wheels'
3+
inputs:
4+
snap7-archive-url:
5+
description: 'Link to download snap7 archive'
6+
required: true
7+
default: 'https://sourceforge.net/projects/snap7/files/1.4.2/snap7-full-1.4.2.7z/download'
8+
runs:
9+
using: "composite"
10+
steps:
11+
- name: Cache snap7-archive
12+
id: snap7-archive
13+
uses: actions/cache@v3
14+
with:
15+
path: snap7-full-1.4.2.7z
16+
key: ${{ inputs.snap7-archive-url }}
17+
18+
- name: Install choco packages
19+
if: steps.snap7-archive.outputs.cache-hit != 'true' && runner.os == 'Windows'
20+
shell: bash
21+
run: choco install --allow-downgrade wget --version 1.20.3.20190531
22+
23+
- name: Get snap7
24+
if: steps.snap7-archive.outputs.cache-hit != 'true'
25+
shell: bash
26+
run: wget -O snap7-full-1.4.2.7z --content-disposition -c ${{ inputs.snap7-archive-url }}
27+
28+
- name: Extract archive
29+
shell: bash
30+
run: 7z x snap7-full-1.4.2.7z
31+
32+
- name: Copy files
33+
shell: bash
34+
run: |
35+
mkdir src
36+
cp snap7-full-1.4.2/release/Wrappers/c-cpp/snap7.h src
37+
cp .github/build_scripts/dummy.c ./
38+
39+
- name: Update wheel
40+
shell: bash
41+
run: python -m pip install --upgrade pip wheel

.github/workflows/build-and-test-arm32v7.yml

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,56 +4,29 @@ on:
44
branches: [master]
55
pull_request:
66
branches: [master]
7-
env:
8-
snap7-archive-url: https://sourceforge.net/projects/snap7/files/1.4.2/snap7-full-1.4.2.7z/download
97
jobs:
108
arm32-build:
119
name: Build arm32 wheel
1210
runs-on: ubuntu-latest
1311
steps:
1412
- name: Checkout
1513
uses: actions/checkout@v3
16-
17-
- name: Cache snap7-archive
18-
id: snap7-archive
19-
uses: actions/cache@v3
20-
with:
21-
path: snap7-full-1.4.2.7z
22-
key: ${{ env.snap7-archive-url }}
23-
24-
- name: Get snap7
25-
if: steps.snap7-archive.outputs.cache-hit != 'true'
26-
run: |
27-
wget -O snap7-full-1.4.2.7z --content-disposition -c ${{ env.snap7-archive-url }}
28-
29-
- name: Extract archive
30-
run: 7z x snap7-full-1.4.2.7z
31-
32-
- name: Copy files
33-
run: |
34-
mkdir src
35-
cp snap7-full-1.4.2/release/Wrappers/c-cpp/snap7.h src
36-
cp .github/build_scripts/dummy.c ./
37-
ls snap7-full-1.4.2
14+
15+
- name: prepare snap7 archive
16+
uses: ./.github/actions/prepare_snap7
3817

3918
- name: Set up QEMU
4019
uses: docker/setup-qemu-action@v2
4120
with:
4221
platforms: arm
4322

44-
- name: Update wheel
45-
run: python -m pip install --upgrade wheel
46-
4723
- name: Build libsnap7.so
4824
run: |
4925
docker run --rm --interactive -v $PWD/snap7-full-1.4.2:/snap7-full-1.4.2 "arm32v7/gcc:latest" /bin/bash -s <<EOF
5026
cd snap7-full-1.4.2/build/unix/
5127
make -f arm_v7_linux.mk all
5228
EOF
5329
54-
- name: tmp check file
55-
run: ls -la snap7-full-1.4.2/build/bin/arm_v7-linux
56-
5730
- name: Build pure python wheel
5831
run: python3 setup.py bdist_wheel --plat-name=linux_armv7l
5932

@@ -68,7 +41,6 @@ jobs:
6841
mkdir -p wheelhouse/linux_armv7l
6942
python3 -m wheel pack $unpack_tmp_dir/$packagename -d wheelhouse/linux_armv7l/
7043
71-
7244
- name: Upload artifacts
7345
uses: actions/upload-artifact@v3
7446
with:
@@ -99,7 +71,8 @@ jobs:
9971

10072
- name: Run tests in docker:arm32v7
10173
run: |
102-
docker run --platform linux/arm/v7 --rm --interactive -v $PWD/test:/test -v $PWD/wheelhouse:/wheelhouse "arm32v7/python:${{ matrix.python-version }}-buster" /bin/bash -s <<EOF
103-
python -m pip install pytest $(ls wheelhouse/linux_armv7l/*.whl)
104-
python -m pytest test/test_server.py test/test_util.py test/test_client.py test/test_mainloop.py test/test_partner.py
74+
docker run --platform linux/arm/v7 --rm --interactive -v $PWD/tests:/tests -v $PWD/setup.cfg:/setup.cfg \
75+
-v $PWD/wheelhouse:/wheelhouse "arm32v7/python:${{ matrix.python-version }}-buster" /bin/bash -s <<EOF
76+
python -m pip install pytest pytest-asyncio $(ls wheelhouse/linux_armv7l/*.whl)
77+
python -m pytest tests/ -m "server or util or client or mainloop or partner"
10578
EOF

.github/workflows/build-and-test-arm64.yml

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,26 @@ on:
44
branches: [master]
55
pull_request:
66
branches: [master]
7-
env:
8-
snap7-archive-url: https://sourceforge.net/projects/snap7/files/1.4.2/snap7-full-1.4.2.7z/download
97
jobs:
108
arm64-build:
119
name: Build arm64 wheel
1210
runs-on: ubuntu-latest
1311
steps:
1412
- name: Checkout
1513
uses: actions/checkout@v3
16-
17-
- name: Cache snap7-archive
18-
id: snap7-archive
19-
uses: actions/cache@v3
20-
with:
21-
path: snap7-full-1.4.2.7z
22-
key: ${{ env.snap7-archive-url }}
23-
24-
- name: Get snap7
25-
if: steps.snap7-archive.outputs.cache-hit != 'true'
26-
run: |
27-
wget -O snap7-full-1.4.2.7z --content-disposition -c ${{ env.snap7-archive-url }}
28-
29-
- name: Extract archive
30-
run: 7z x snap7-full-1.4.2.7z
14+
15+
- name: prepare snap7 archive
16+
uses: ./.github/actions/prepare_snap7
3117

3218
- name: Copy files
3319
run: |
34-
mkdir src
35-
cp snap7-full-1.4.2/release/Wrappers/c-cpp/snap7.h src
36-
cp .github/build_scripts/dummy.c ./
3720
cp .github/build_scripts/aarch64-linux-gnu.mk snap7-full-1.4.2/build/unix/
3821
3922
- name: Set up QEMU
4023
uses: docker/setup-qemu-action@v2
4124
with:
4225
platforms: arm64
4326

44-
- name: Update wheel
45-
run: python -m pip install --upgrade wheel
46-
4727
- name: Build wheels
4828
uses: pypa/[email protected]
4929
with:
@@ -72,7 +52,7 @@ jobs:
7252
runs-on: ubuntu-latest
7353
strategy:
7454
matrix:
75-
python-version: ["3.7", "3.8", "3.9", "3.10"]
55+
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
7656
steps:
7757
- name: Checkout
7858
uses: actions/checkout@v3
@@ -90,7 +70,8 @@ jobs:
9070

9171
- name: Run tests in docker:arm64v8
9272
run: |
93-
docker run --rm --interactive -v $PWD/test:/test -v $PWD/wheelhouse:/wheelhouse "arm64v8/python:${{ matrix.python-version }}-buster" /bin/bash -s <<EOF
94-
python -m pip install pytest $(ls wheelhouse/${{ runner.os }}/*.whl)
95-
python -m pytest test/test_server.py test/test_util.py test/test_client.py test/test_mainloop.py test/test_partner.py
73+
docker run --rm --interactive -v $PWD/tests:/tests -v $PWD/setup.cfg:/setup.cfg -v $PWD/wheelhouse:/wheelhouse \
74+
"arm64v8/python:${{ matrix.python-version }}-buster" /bin/bash -s <<EOF
75+
python3 -m pip install pytest pytest-asyncio $(ls wheelhouse/${{ runner.os }}/*.whl)
76+
python3 -m pytest tests/ -m server -m util -m client -m mainloop -m partner
9677
EOF

.github/workflows/build-and-test.yml

Lines changed: 13 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ on:
44
branches: [master]
55
pull_request:
66
branches: [master]
7-
env:
8-
snap7-archive-url: https://sourceforge.net/projects/snap7/files/1.4.2/snap7-full-1.4.2.7z/download
97
jobs:
108
windows-build:
119
name: Build wheel for windows
@@ -14,26 +12,8 @@ jobs:
1412
- name: Checkout
1513
uses: actions/checkout@v3
1614

17-
- name: Install choco packages
18-
run: choco install --allow-downgrade wget --version 1.20.3.20190531
19-
20-
- name: Cache snap7-archive
21-
id: snap7-archive
22-
uses: actions/cache@v3
23-
with:
24-
path: snap7-full-1.4.2.7z
25-
key: ${{ env.snap7-archive-url }}
26-
27-
- name: Get snap7
28-
if: steps.snap7-archive.outputs.cache-hit != 'true'
29-
run: |
30-
wget -O snap7-full-1.4.2.7z --content-disposition -c ${{ env.snap7-archive-url }}
31-
32-
- name: Extract archive
33-
run: 7z x snap7-full-1.4.2.7z
34-
35-
- name: Update wheel
36-
run: python3 -m pip install wheel --upgrade
15+
- name: prepare snap7 archive
16+
uses: ./.github/actions/prepare_snap7
3717

3818
- name: Build wheel
3919
run: python3 setup.py bdist_wheel --plat-name win_amd64
@@ -54,28 +34,8 @@ jobs:
5434
- name: Checkout
5535
uses: actions/checkout@v3
5636

57-
- name: Cache snap7-archive
58-
id: snap7-archive
59-
uses: actions/cache@v3
60-
with:
61-
path: snap7-full-1.4.2.7z
62-
key: ${{ env.snap7-archive-url }}
63-
64-
- name: Get snap7
65-
if: steps.snap7-archive.outputs.cache-hit != 'true'
66-
run: wget -O snap7-full-1.4.2.7z --content-disposition -c ${{ env.snap7-archive-url }}
67-
68-
- name: Extract archive
69-
run: 7z x snap7-full-1.4.2.7z
70-
71-
- name: Copy files
72-
run: |
73-
mkdir src
74-
cp snap7-full-1.4.2/release/Wrappers/c-cpp/snap7.h src
75-
cp .github/build_scripts/dummy.c ./
76-
77-
- name: Update wheel
78-
run: python -m pip install --upgrade wheel
37+
- name: prepare snap7 archive
38+
uses: ./.github/actions/prepare_snap7
7939

8040
- name: Build pure python wheel
8141
run: python3 setup.py bdist_wheel --plat-name=manylinux1_x86_64
@@ -105,27 +65,12 @@ jobs:
10565
steps:
10666
- name: Checkout
10767
uses: actions/checkout@v3
108-
109-
- name: Cache snap7-archive
110-
id: snap7-archive
111-
uses: actions/cache@v3
112-
with:
113-
path: snap7-full-1.4.2.7z
114-
key: ${{ env.snap7-archive-url }}
115-
116-
- name: Get snap7
117-
if: steps.snap7-archive.outputs.cache-hit != 'true'
118-
run: |
119-
wget -nv -O snap7-full-1.4.2.7z --content-disposition -c ${{ env.snap7-archive-url }}
120-
121-
- name: Extract archive
122-
run: 7z x snap7-full-1.4.2.7z
68+
69+
- name: prepare snap7 archive
70+
uses: ./.github/actions/prepare_snap7
12371

12472
- name: Copy files
12573
run: |
126-
mkdir src
127-
cp snap7-full-1.4.2/release/Wrappers/c-cpp/snap7.h src
128-
cp .github/build_scripts/dummy.c ./
12974
cp .github/build_scripts/arm64_osx.mk snap7-full-1.4.2/build/osx/
13075
pushd snap7-full-1.4.2/build/osx/
13176
make -f x86_64_osx.mk all
@@ -165,7 +110,7 @@ jobs:
165110
strategy:
166111
matrix:
167112
os: [ubuntu-latest, macos-latest, windows-latest]
168-
python-version: ["3.7", "3.8", "3.9", "3.10"]
113+
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
169114
steps:
170115
- name: Checkout
171116
uses: actions/checkout@v3
@@ -178,7 +123,7 @@ jobs:
178123
- name: Install pytest
179124
run: |
180125
python3 -m pip install --upgrade pip
181-
python3 -m pip install pytest
126+
python3 -m pip install pytest pytest-asyncio
182127
183128
- name: Download artifacts
184129
uses: actions/download-artifact@v3
@@ -192,16 +137,16 @@ jobs:
192137
- name: Run pytest
193138
run: |
194139
which pytest
195-
pytest test/test_server.py test/test_util.py test/test_client.py test/test_mainloop.py
140+
pytest -m "server or util or client or mainloop"
196141
197142
- name: Run tests required sudo
198143
if: ${{ runner.os == 'Linux'}}
199-
run: sudo /opt/hostedtoolcache/Python/${{ matrix.python-version }}*/x64/bin/pytest test/test_partner.py
144+
run: sudo /opt/hostedtoolcache/Python/${{ matrix.python-version }}*/x64/bin/pytest -m partner
200145

201146
- name: Run tests required sudo
202147
if: ${{ runner.os == 'macOS'}}
203-
run: sudo pytest test/test_partner.py
148+
run: sudo pytest -m partner
204149

205150
- name: Run tests required sudo
206151
if: ${{ runner.os == 'Windows'}}
207-
run: pytest test/test_partner.py
152+
run: pytest -m partner

.github/workflows/flake8.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ jobs:
2020
sudo python3 -m pip install flake8
2121
- name: Lint with flake8
2222
run: |
23-
flake8 --count --select=E9,F63,F7,F82 --show-source --statistics snap7 test
24-
flake8 --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics snap7 test
23+
flake8 --count --select=E9,F63,F7,F82 --show-source --statistics snap7 tests
24+
flake8 --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics snap7 tests

.github/workflows/linux.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ jobs:
3232
- name: Run pytest
3333
run: |
3434
which pytest
35-
pytest test/test_server.py test/test_client.py test/test_util.py test/test_mainloop.py
36-
sudo /opt/hostedtoolcache/Python/${{ matrix.python-version }}*/x64/bin/pytest test/test_partner.py
35+
pytest -m "server or util or client or mainloop"
36+
sudo /opt/hostedtoolcache/Python/${{ matrix.python-version }}*/x64/bin/pytest -m partner

.github/workflows/osx.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
run: python3 -m pip install .[test]
1919
- name: Run pytest
2020
run: |
21-
pytest test/test_server.py test/test_client.py test/test_util.py test/test_mainloop.py
22-
sudo pytest test/test_partner.py
21+
pytest -m "server or util or client or mainloop"
22+
sudo pytest -m partner
2323
2424

.github/workflows/pycodestyle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ jobs:
1919
sudo python3 -m pip install --upgrade pip
2020
sudo python3 -m pip install pycodestyle
2121
- name: Run pycodestyle
22-
run: pycodestyle snap7 test
22+
run: pycodestyle snap7 tests

.github/workflows/test-pypi-packages.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
strategy:
77
matrix:
88
os: [ubuntu-latest, macos-latest, windows-latest]
9-
python-version: ["3.7", "3.8", "3.9", "3.10"]
9+
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
1010
steps:
1111
- name: Checkout
1212
uses: actions/checkout@v3
@@ -27,16 +27,16 @@ jobs:
2727
- name: Run pytest
2828
run: |
2929
which pytest
30-
pytest test/test_server.py test/test_util.py test/test_client.py
30+
pytest -m "server or util or client or mainloop"
3131
3232
- name: Run tests required sudo
3333
if: ${{ runner.os == 'Linux'}}
34-
run: sudo /opt/hostedtoolcache/Python/${{ matrix.python-version }}*/x64/bin/pytest test/test_partner.py
35-
36-
- name: Run test_partner.py on windows
37-
if: ${{ runner.os == 'Windows' }}
38-
run: pytest test/test_partner.py
34+
run: sudo /opt/hostedtoolcache/Python/${{ matrix.python-version }}*/x64/bin/pytest -m partner
3935

4036
- name: Run tests required sudo
4137
if: ${{ runner.os == 'macOS'}}
42-
run: sudo pytest test/test_partner.py
38+
run: sudo pytest -m partner
39+
40+
- name: Run tests required sudo
41+
if: ${{ runner.os == 'Windows'}}
42+
run: pytest -m partner

0 commit comments

Comments
 (0)