diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000..688b34f --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,68 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +name: "CodeQL" + +on: + push: + branches: [main] + pull_request: + # The branches below must be a subset of the branches above + branches: [main] + schedule: + - cron: '0 6 * * 4' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + language: ['python'] + env: + PIP_INDEX_URL: https://pypi.sunet.se/simple/ + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + # We must fetch at least the immediate parents so that if this is + # a pull request then we can checkout the head. + fetch-depth: 2 + + # If this run was triggered by a pull request event, then checkout + # the head of the pull request instead of the merge commit. + - run: git checkout HEAD^2 + if: ${{ github.event_name == 'pull_request' }} + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml new file mode 100644 index 0000000..9698001 --- /dev/null +++ b/.github/workflows/run-tests.yaml @@ -0,0 +1,84 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Python package + +on: [push, pull_request] + +jobs: + + unittests_legacy: + runs-on: ubuntu-18.04 + strategy: + matrix: + python-version: ["2.7", "3.6"] + + 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 packages + run: | + sudo apt-get install swig softhsm2 opensc libengine-pkcs11-openssl + + - name: Install dependencies + run: | + python -m pip install --upgrade pip wheel + pip install -r requirements.txt + python setup.py develop + pip install nose + + - name: Test with nosetest + run: | + python setup.py test + + unittests: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["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 packages + run: | + sudo apt install swig softhsm2 opensc libengine-pkcs11-openssl + + - name: Install dependencies + run: | + python -m pip install --upgrade pip wheel + pip install -r requirements.txt + pip install pytest + + - name: Test with pytest + run: | + make test + +# typecheck: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v3 +# +# - name: Set up Python 3.x +# uses: actions/setup-python@v4 +# with: +# python-version: 3.x +# +# - name: Install dependencies +# run: | +# python -m pip install --upgrade pip +# pip install -r requirements/test_requirements.txt +# +# - name: Run mypy to check types +# run: | +# mypy --version +# make typecheck + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5e796dd --- /dev/null +++ b/Makefile @@ -0,0 +1,6 @@ +TOPDIR:= $(abspath .) +SRCDIR= $(TOPDIR)/src +SOURCE= $(SRCDIR)/pyeleven + +test: + PYTHONPATH=$(SRCDIR) pytest -vvv -ra --log-cli-level DEBUG diff --git a/src/pyeleven/test/__init__.py b/src/pyeleven/test/__init__.py index 927b2e3..d6943d1 100644 --- a/src/pyeleven/test/__init__.py +++ b/src/pyeleven/test/__init__.py @@ -24,7 +24,11 @@ def _find_alts(alts): '/usr/lib/softhsm/libsofthsm2.so', '/usr/lib/x86_64-linux-gnu/softhsm/libsofthsm2.so' ]) -P11_ENGINE = _find_alts(['/usr/lib/engines/engine_pkcs11.so', '/usr/lib/x86_64-linux-gnu/engines-1.1/libpkcs11.so']) +P11_ENGINE = _find_alts([ + '/usr/lib/engines/engine_pkcs11.so', + '/usr/lib/x86_64-linux-gnu/engines-1.1/libpkcs11.so', + '/usr/lib/x86_64-linux-gnu/engines-3/libpkcs11.so' +]) P11_SPY = _find_alts(['/usr/lib/pkcs11/pkcs11-spy.so']) PKCS11_TOOL = _find_alts(['/usr/bin/pkcs11-tool']) OPENSC_TOOL = _find_alts(['/usr/bin/opensc-tool'])