Skip to content

Commit

Permalink
Merge branch 'main' into lv/move_compliance_check_to_sdk
Browse files Browse the repository at this point in the history
# Conflicts:
#	poetry.lock
#	pyproject.toml
  • Loading branch information
lvoloshyn-sekoia committed Oct 7, 2024
2 parents 46c87b9 + 08ee681 commit 4b9a75d
Show file tree
Hide file tree
Showing 19 changed files with 618 additions and 902 deletions.
68 changes: 52 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,57 @@ jobs:
Lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.11"
python-version: "3.12"

- name: Install Poetry
run: |
pip install poetry
poetry config virtualenvs.in-project true
- name: Run Ruff
- name: Check `poetry.lock` consistency
run: |
poetry lock --check
- name: Install linting dependencies
run: |
poetry install --only=lint
- name: Run Ruff (linter)
run: |
poetry run pip install ruff
poetry run ruff check --output-format=github .
- uses: psf/black@stable
- name: Run Ruff (formater)
run: |
poetry run ruff format
- name: Execute Mypy
run: |
poetry run pip install mypy
mkdir -p .mypy_cache
poetry run mypy --install-types --non-interactive --hide-error-context sekoia_automation
poetry run mypy
Test:
Test-matrix:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
python-version:
- '3.10'
- '3.11'
- '3.12'

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.11"
python-version: ${{ matrix.python-version }}

- name: Install Poetry
run: |
Expand All @@ -59,20 +76,39 @@ jobs:
poetry run python -m pytest --junit-xml=junit.xml --cov-report term --cov-report xml:coverage.xml --cov=sekoia_automation
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v3
if: always() && matrix.python-version == 3.12
uses: actions/upload-artifact@v4
with:
name: Unit Test Results
path: junit.xml

- name: Code Coverage
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
if: matrix.python-version == 3.12
with:
fail_ci_if_error: true
files: coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}

Test:
runs-on: ubuntu-latest
needs:
- Test-matrix
if: always()
steps:
- name: Successful deploy
if: ${{ !(contains(needs.*.result, 'failure')) }}
run: exit 0

- name: Failing deploy
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1

EventFile:
runs-on: ubuntu-latest
steps:
- name: Upload
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Event File
path: ${{ github.event_path }}
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ jobs:
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.11"

Expand All @@ -26,4 +26,4 @@ jobs:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
poetry config pypi-token.pypi $PYPI_TOKEN
poetry publish
poetry publish
43 changes: 7 additions & 36 deletions .github/workflows/test_results.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,45 +12,16 @@ jobs:
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion != 'skipped'
steps:
- name: 'Download artifact'
uses: actions/[email protected]
- name: Download and Extract Artifacts
uses: dawidd6/action-download-artifact@e7466d1a7587ed14867642c2ca74b5bcc1e19a2d
with:
script: |
var artifacts = await github.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{github.event.workflow_run.id }},
});
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "Unit Test Results"
})[0];
var download = await github.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
var fs = require('fs');
fs.writeFileSync('${{github.workspace}}/Unit Test Results.zip', Buffer.from(download.data));
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "Event File"
})[0];
var download = await github.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
var fs = require('fs');
fs.writeFileSync('${{github.workspace}}/Event File.zip', Buffer.from(download.data));
- name: "Unzip Artifacts"
run: |
unzip 'Unit Test Results.zip'
unzip 'Event File.zip'
run_id: ${{ github.event.workflow_run.id }}
path: artifacts

- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
with:
commit: ${{ github.event.workflow_run.head_sha }}
event_file: event.json
event_file: artifacts/Event File/event.json
event_name: ${{ github.event.workflow_run.event }}
files: "*.xml"
files: "artifacts/**/*.xml"
26 changes: 22 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## 1.15.1 - 2024-010-04

### Changed

- Improve retry on some HTTP errors

## [1.15.0] - 2024-09-28

### Changed

- Make the minimal Python version to 3.10.
- Replace isort, black and autoflake with Ruff.
- Update Mypy configuration.
- Improve CI to test the package with several versions of Python.
- Update some dependencies to their latest version
(`requests-ratelimiter`, `typer`, `prometheus-client`) and some
devel ones (`pytest`, `pytest-asyncio`, `pytest-env`, `faker`).

## [1.14.1] - 2024-09-10

### Fixed
Expand All @@ -22,7 +40,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Increase number of retries and time between retries when sending requests
- Increase number of retries and time between retries when sending requests

## [1.13.0] - 2024-04-22

Expand Down Expand Up @@ -71,7 +89,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Add heartbeat in triggers
- Add heartbeat in triggers
The heartbeat allows to mark the trigger as not alive if no heartbeat was received for a certain amount of time.
To support this feature triggers must:
- Set the `last_heartbeat_threshold` class attribute to a value greater than 0
Expand Down Expand Up @@ -103,7 +121,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Add graceful delay on startup where unhandled errors won't trigger a critical exit
- Add graceful delay on startup where unhandled errors won't trigger a critical exit

## [1.7.0] - 2023-11-07

Expand Down Expand Up @@ -147,7 +165,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Improve error message when it is not possible to access the data storage
- Remove `chunk_size` parameter from configuration
- Try to take Intake URL from an environment var first
- Try to take Intake URL from an environment var first

### Fixed

Expand Down
Loading

0 comments on commit 4b9a75d

Please sign in to comment.