Skip to content

Commit

Permalink
Merge pull request #7 from isra17/gh-actions
Browse files Browse the repository at this point in the history
Gh actions
  • Loading branch information
isra17 authored Jul 20, 2022
2 parents c3ecf92 + 3cc59e2 commit 58cc6ad
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 2 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 }}
2 changes: 0 additions & 2 deletions requirements.txt

This file was deleted.

9 changes: 9 additions & 0 deletions tests/test_fileform.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -66,13 +73,15 @@ 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:
firstheader = fileform._find_firstheader(nsis_file)
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:
Expand Down

0 comments on commit 58cc6ad

Please sign in to comment.