Fix test CI/CD
parent
a4a59a7ba8
commit
0a37bcc259
|
@ -0,0 +1,54 @@
|
||||||
|
name: cti-python-stix2 release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Set up Python 3.12
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: 3.12
|
||||||
|
- name: Install and update essential dependencies
|
||||||
|
run: |
|
||||||
|
pip install -U pip setuptools
|
||||||
|
pip install tox-gh-actions
|
||||||
|
pip install codecov
|
||||||
|
- name: Test with Tox
|
||||||
|
run: |
|
||||||
|
tox
|
||||||
|
- name: Upload coverage information to Codecov
|
||||||
|
uses: codecov/codecov-action@v4.2.0
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
verbose: true
|
||||||
|
- name: Upload package artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: python-package-distributions
|
||||||
|
path: dist/
|
||||||
|
|
||||||
|
publish-to-pypi:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: build
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
id-token: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Download dist files
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: python-package-distributions
|
||||||
|
path: dist/
|
||||||
|
|
||||||
|
- name: Publish to PyPI
|
||||||
|
uses: pypa/gh-action-pypi-publish@release/v1
|
||||||
|
with:
|
||||||
|
skip-existing: true
|
|
@ -1,15 +1,16 @@
|
||||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
|
name: cti-python-stix2 test
|
||||||
|
|
||||||
name: cti-python-stix2 test harness
|
on:
|
||||||
on: [push, pull_request]
|
push:
|
||||||
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
test:
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
python-version: [3.8, 3.9, '3.10', '3.11', '3.12']
|
python-version: ['3.9', '3.10', '3.11', '3.12']
|
||||||
|
|
||||||
name: Python ${{ matrix.python-version }} Build
|
name: Python ${{ matrix.python-version }} Build
|
||||||
steps:
|
steps:
|
||||||
|
@ -26,9 +27,30 @@ jobs:
|
||||||
- name: Test with Tox
|
- name: Test with Tox
|
||||||
run: |
|
run: |
|
||||||
tox
|
tox
|
||||||
- name: Upload coverage information to Codecov
|
- name: Upload package artifact
|
||||||
uses: codecov/codecov-action@v4.2.0
|
if: ${{ matrix.python-version == '3.12' }}
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
name: python-package-distributions
|
||||||
fail_ci_if_error: false # optional (default = false)
|
path: dist/
|
||||||
verbose: true # optional (default = false)
|
|
||||||
|
publish-to-test-pypi:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: test
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
id-token: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Download dist files
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: python-package-distributions
|
||||||
|
path: dist/
|
||||||
|
|
||||||
|
- name: Publish to Test PyPI
|
||||||
|
if: ${{ github.event_name == 'push' }}
|
||||||
|
uses: pypa/gh-action-pypi-publish@release/v1
|
||||||
|
with:
|
||||||
|
skip-existing: true
|
||||||
|
repository-url: https://test.pypi.org/legacy/
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v3.4.0
|
rev: v4.5.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
- id: check-merge-conflict
|
- id: check-merge-conflict
|
||||||
|
@ -9,7 +9,7 @@ repos:
|
||||||
hooks:
|
hooks:
|
||||||
- id: add-trailing-comma
|
- id: add-trailing-comma
|
||||||
- repo: https://github.com/PyCQA/flake8
|
- repo: https://github.com/PyCQA/flake8
|
||||||
rev: 3.8.4
|
rev: 7.0.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: flake8
|
- id: flake8
|
||||||
name: Check project styling
|
name: Check project styling
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[bumpversion]
|
[bumpversion]
|
||||||
current_version = 3.0.1.1
|
current_version = 3.0.1.2
|
||||||
commit = True
|
commit = True
|
||||||
tag = True
|
tag = True
|
||||||
|
|
||||||
|
|
9
setup.py
9
setup.py
|
@ -1,6 +1,8 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
from codecs import open
|
from codecs import open
|
||||||
|
from importlib import metadata
|
||||||
import os.path
|
import os.path
|
||||||
|
import sys
|
||||||
|
|
||||||
from setuptools import find_packages, setup
|
from setuptools import find_packages, setup
|
||||||
|
|
||||||
|
@ -22,6 +24,13 @@ def get_long_description():
|
||||||
return f.read()
|
return f.read()
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
metadata.version("stix2")
|
||||||
|
sys.exit("Error: 'stix2' is installed. Uninstall it before proceeding.")
|
||||||
|
except metadata.PackageNotFoundError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='misp-lib-stix2',
|
name='misp-lib-stix2',
|
||||||
version=get_version(),
|
version=get_version(),
|
||||||
|
|
|
@ -151,6 +151,7 @@ def test_filesystem_source_bad_stix_file(fs_source, bad_stix_files):
|
||||||
except STIXError as e:
|
except STIXError as e:
|
||||||
assert "Can't parse object with no 'type' property" in str(e)
|
assert "Can't parse object with no 'type' property" in str(e)
|
||||||
|
|
||||||
|
|
||||||
def test_filesystem_sink_add_pretty_true(fs_sink, fs_source):
|
def test_filesystem_sink_add_pretty_true(fs_sink, fs_source):
|
||||||
"""Test adding a STIX object with pretty=True."""
|
"""Test adding a STIX object with pretty=True."""
|
||||||
camp1 = stix2.v21.Campaign(
|
camp1 = stix2.v21.Campaign(
|
||||||
|
@ -169,6 +170,7 @@ def test_filesystem_sink_add_pretty_true(fs_sink, fs_source):
|
||||||
|
|
||||||
os.remove(filepath)
|
os.remove(filepath)
|
||||||
|
|
||||||
|
|
||||||
def test_filesystem_sink_add_pretty_false(fs_sink, fs_source):
|
def test_filesystem_sink_add_pretty_false(fs_sink, fs_source):
|
||||||
"""Test adding a STIX object with pretty=False."""
|
"""Test adding a STIX object with pretty=False."""
|
||||||
camp1 = stix2.v21.Campaign(
|
camp1 = stix2.v21.Campaign(
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
__version__ = "3.0.1.1"
|
__version__ = "3.0.1.2"
|
||||||
|
|
||||||
DEFAULT_VERSION = '2.1' # Default version will always be the latest STIX 2.X version
|
DEFAULT_VERSION = '2.1' # Default version will always be the latest STIX 2.X version
|
||||||
|
|
8
tox.ini
8
tox.ini
|
@ -1,5 +1,5 @@
|
||||||
[tox]
|
[tox]
|
||||||
envlist = py38,py39,py310,py311,py312,packaging,pre-commit-check
|
envlist = py39,py310,py311,py312,packaging,pre-commit-check
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
deps =
|
deps =
|
||||||
|
@ -18,6 +18,7 @@ passenv = GITHUB_*
|
||||||
|
|
||||||
[testenv:packaging]
|
[testenv:packaging]
|
||||||
deps =
|
deps =
|
||||||
|
setuptools
|
||||||
twine
|
twine
|
||||||
commands =
|
commands =
|
||||||
python setup.py sdist bdist_wheel --universal
|
python setup.py sdist bdist_wheel --universal
|
||||||
|
@ -31,8 +32,7 @@ commands =
|
||||||
|
|
||||||
[gh-actions]
|
[gh-actions]
|
||||||
python =
|
python =
|
||||||
3.8: py38
|
|
||||||
3.9: py39
|
3.9: py39
|
||||||
3.10: py310
|
3.10: py310
|
||||||
3.11: py311, packaging, pre-commit-check
|
3.11: py311
|
||||||
3.12: py312
|
3.12: py312, packaging, pre-commit-check
|
||||||
|
|
Loading…
Reference in New Issue