From 9f732e30c82b0f9f1214a710e6073d51e07f95f1 Mon Sep 17 00:00:00 2001 From: isra17 Date: Tue, 19 Jul 2022 21:58:36 -0400 Subject: [PATCH 1/2] Add github actions --- .github/workflows/ci.yml | 26 ++++++++++++++++++++++++++ requirements.txt | 2 -- tests/test_fileform.py | 9 +++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 requirements.txt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..38af095 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,26 @@ +name: Python package +on: [push] +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["2.7", "3.5", "3.9", "3.10"] + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + sudo apt-get install -y swig + python -m pip install --upgrade pip setuptools wheel + pip install pytest future + pip install -e . + - name: Test with pytest + run: | + python -m pytest -v + - name: Run on sample + run: | + ./nsisdump.py tests/samples/example1.exe diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 85d9cbd..0000000 --- a/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -pytest==2.8.7 -future==0.15.2 diff --git a/tests/test_fileform.py b/tests/test_fileform.py index 3882dae..47539b7 100644 --- a/tests/test_fileform.py +++ b/tests/test_fileform.py @@ -1,7 +1,14 @@ from nrs import fileform import os +import pytest import utils +try: + import lzma + has_lzma = True +except ImportError: + has_lzma = False + def test_findheader_not_found(): # Header should not be found in non-nsisi files. with open(os.path.join(utils.SAMPLES_DIR, 'empty'), 'rb') as empty: @@ -66,6 +73,7 @@ def test_extract_zlib_solid(): header = fileform._extract_header(nsis_file, firstheader) assert header is not None +@pytest.mark.skipif(not has_lzma, reason="no lzma support") def test_extract_lzma(): with open(os.path.join(utils.SAMPLES_DIR, 'example_lzma.exe'), 'rb') \ as nsis_file: @@ -73,6 +81,7 @@ def test_extract_lzma(): header = fileform._extract_header(nsis_file, firstheader) assert header is not None +@pytest.mark.skipif(not has_lzma, reason="no lzma support") def test_extract_lzma_solid(): with open(os.path.join(utils.SAMPLES_DIR, 'example_lzma_solid.exe'), 'rb') \ as nsis_file: From 3cc59e2e8caf3dc0d4dab49a97a8369cc35646b7 Mon Sep 17 00:00:00 2001 From: isra17 Date: Tue, 19 Jul 2022 22:26:34 -0400 Subject: [PATCH 2/2] Add release action --- .github/workflows/release.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..8f0a51d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,26 @@ +name: Upload Python Package + +on: + release: + types: [published] + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + - name: Build package + run: python -m build + - name: Publish package + uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }}