Skip to content

Commit

Permalink
Merge pull request #6 from IdentityPython/lundberg_gh_actions
Browse files Browse the repository at this point in the history
add github actions
  • Loading branch information
johanlundberg authored Jan 19, 2023
2 parents f9d522e + ae437ea commit 7ee6035
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 1 deletion.
68 changes: 68 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -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
84 changes: 84 additions & 0 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
@@ -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

6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
TOPDIR:= $(abspath .)
SRCDIR= $(TOPDIR)/src
SOURCE= $(SRCDIR)/pyeleven

test:
PYTHONPATH=$(SRCDIR) pytest -vvv -ra --log-cli-level DEBUG
6 changes: 5 additions & 1 deletion src/pyeleven/test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down

0 comments on commit 7ee6035

Please sign in to comment.