From c635398465b42bf8f340dc57963ffea471c8e5a0 Mon Sep 17 00:00:00 2001 From: Stefano Ortolani Date: Mon, 16 Dec 2024 14:34:43 +0000 Subject: [PATCH] Fix CI/CD --- .github/workflows/python-ci-tests.yml | 25 +++++++++++++++++++-- .pre-commit-config.yaml | 4 ++-- setup.py | 10 +++++++++ stix2/test/v21/test_datastore_filesystem.py | 2 ++ tox.ini | 6 ++--- 5 files changed, 40 insertions(+), 7 deletions(-) diff --git a/.github/workflows/python-ci-tests.yml b/.github/workflows/python-ci-tests.yml index 47f860e1..42e04b26 100644 --- a/.github/workflows/python-ci-tests.yml +++ b/.github/workflows/python-ci-tests.yml @@ -4,12 +4,12 @@ name: cti-python-stix2 test harness on: [push, pull_request] jobs: - build: + test: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.8, 3.9, '3.10', '3.11', '3.12'] + python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] name: Python ${{ matrix.python-version }} Build steps: @@ -32,3 +32,24 @@ jobs: token: ${{ secrets.CODECOV_TOKEN }} fail_ci_if_error: false # optional (default = false) 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/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c39aaf6d..a4166a6e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.4.0 + rev: v4.5.0 hooks: - id: trailing-whitespace - id: check-merge-conflict @@ -9,7 +9,7 @@ repos: hooks: - id: add-trailing-comma - repo: https://github.com/PyCQA/flake8 - rev: 3.8.4 + rev: 7.0.0 hooks: - id: flake8 name: Check project styling diff --git a/setup.py b/setup.py index d0d8fe77..f4bd85ad 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,9 @@ #!/usr/bin/env python from codecs import open import os.path +import sys +import pkg_resources from setuptools import find_packages, setup BASE_DIR = os.path.dirname(os.path.abspath(__file__)) @@ -22,6 +24,13 @@ def get_long_description(): return f.read() +try: + pkg_resources.get_distribution("stix2") + sys.exit("Error: 'stix2' is installed. Uninstall it before proceeding.") +except pkg_resources.DistributionNotFound: + pass + + setup( name='misp-lib-stix2', version=get_version(), @@ -43,6 +52,7 @@ def get_long_description(): 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', 'Programming Language :: Python :: 3.12', + 'Programming Language :: Python :: 3.13', ], keywords='stix stix2 json cti cyber threat intelligence', packages=find_packages(exclude=['*.test', '*.test.*']), diff --git a/stix2/test/v21/test_datastore_filesystem.py b/stix2/test/v21/test_datastore_filesystem.py index 39b45578..037146e6 100644 --- a/stix2/test/v21/test_datastore_filesystem.py +++ b/stix2/test/v21/test_datastore_filesystem.py @@ -151,6 +151,7 @@ def test_filesystem_source_bad_stix_file(fs_source, bad_stix_files): except STIXError as e: assert "Can't parse object with no 'type' property" in str(e) + def test_filesystem_sink_add_pretty_true(fs_sink, fs_source): """Test adding a STIX object with pretty=True.""" camp1 = stix2.v21.Campaign( @@ -169,6 +170,7 @@ def test_filesystem_sink_add_pretty_true(fs_sink, fs_source): os.remove(filepath) + def test_filesystem_sink_add_pretty_false(fs_sink, fs_source): """Test adding a STIX object with pretty=False.""" camp1 = stix2.v21.Campaign( diff --git a/tox.ini b/tox.ini index bc7bd5b6..f31678aa 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py38,py39,py310,py311,py312,packaging,pre-commit-check +envlist = py39,py310,py311,py312,py312,packaging,pre-commit-check [testenv] deps = @@ -31,8 +31,8 @@ commands = [gh-actions] python = - 3.8: py38 3.9: py39 3.10: py310 - 3.11: py311, packaging, pre-commit-check + 3.11: py311 3.12: py312 + 3.13: py313, packaging, pre-commit-check