Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 48 additions & 29 deletions .github/workflows/run-unit-tests.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
name: Run unit tests
name: CI

on:
workflow_dispatch:
pull_request:
push:
branches:
- main
branches: [main]
pull_request:

permissions:
contents: read
Expand All @@ -17,9 +15,27 @@ env:
POSTGRES_INITDB_ARGS: --encoding=UTF-8 --lc-collate=en_US.UTF-8 --lc-ctype=en_US.UTF-8

jobs:
run-unit-tests:
runs-on: ubuntu-24.04
check-commits:
name: Validate Commits
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: commitizen-tools/commitizen-action@master
with:
push: false
commit: true

test:
name: Test (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]

services:
postgres:
image: postgres:17
Expand All @@ -36,40 +52,43 @@ jobs:
ports:
- 5432:5432

strategy:
max-parallel: 4
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]

steps:
- name: Checkout code
uses: actions/checkout@v4

- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install universal ctags and xgettext
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y universal-ctags gettext

- name: Install dependencies
- name: Install project dependencies
run: make dev envfile

- name: Validate code format
- name: Linting & Formatting
run: make check

- name: Check Django deployment settings
run: make check-deploy

- name: Build the documentation
run: make docs

- name: Run tests

- name: Validation Checks
run: |
make check-deploy
make docs

- name: Run Unit Tests
run: .venv/bin/python manage.py test --verbosity=2 --noinput
env:
SCANCODEIO_DB_NAME: ${{ env.POSTGRES_DB }}
SCANCODEIO_DB_USER: ${{ env.POSTGRES_USER }}
SCANCODEIO_DB_PASSWORD: ${{ env.POSTGRES_PASSWORD }}

build-check:
name: Build Verification
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- run: python -m pip install build
- run: python -m build
45 changes: 0 additions & 45 deletions .github/workflows/publish-pypi-release.yml

This file was deleted.

97 changes: 97 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Release Pipeline

on:
push:
branches:
- main

permissions:
contents: write
pull-requests: write
packages: write

jobs:
# Self-contained safety check to ensure we never release broken code
# even if CI passed on the PR, we double-check the exact commit on main.
safety-check:
name: Pre-Release Safety Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y universal-ctags gettext
make dev envfile
- name: Verify Linting
run: make check
- name: Verify Build
run: |
python -m pip install build
python -m build

release:
name: Create Release
needs: [safety-check]
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
steps:
- uses: google-github-actions/release-please-action@v4
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}
config-file: release-please-config.json
manifest-file: .release-please-manifest.json

publish-pypi:
name: Publish to PyPI
needs: [release]
if: needs.release.outputs.release_created == 'true'
runs-on: ubuntu-latest
permissions:
id-token: write # Mandaory for trusted publishing
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install build tools
run: python -m pip install build
- name: Build artifacts
run: python -m build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Upload Release Assets
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.release.outputs.tag_name }}
files: dist/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish-docker:
name: Publish Docker Image
needs: [release]
if: needs.release.outputs.release_created == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ghcr.io/${{ github.repository }}:${{ needs.release.outputs.tag_name }},ghcr.io/${{ github.repository }}:latest
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
repos:
- repo: https://github.com/commitizen-tools/commitizen
rev: v4.1.0
hooks:
- id: commitizen
stages: [commit-msg]
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "36.1.0"
}
41 changes: 41 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Contributing to ScanCode.io

## Commit Message Convention

We use [Conventional Commits](https://www.conventionalcommits.org/) to automate our release process.
This specification is **mandatory** for all commits.

### Format
```
<type>(<scope>): <subject>
<BLANK LINE>
<body>
```

### Allowed Types
- **feat**: A new feature (triggers MINOR release)
- **fix**: A bug fix (triggers PATCH release)
- **docs**: Documentation only changes
- **style**: Changes that do not affect the meaning of the code (white-space, formatting, etc)
- **refactor**: A code change that neither fixes a bug nor adds a feature
- **perf**: A code change that improves performance
- **test**: Adding missing tests or correcting existing tests
- **build**: Changes that affect the build system or external dependencies
- **ci**: Changes to our CI configuration files and scripts
- **chore**: Other changes that don't modify src or test files

### Breaking Changes
To indicate a breaking change, add `!` after the type/scope or add `BREAKING CHANGE:` in the footer. This triggers a MAJOR release.

Example:
```
feat(api)!: remove support for v1 endpoints
```

### Pre-commit Hooks
We recommend installing pre-commit hooks to ensure your commits are valid before pushing:

```bash
pip install pre-commit
pre-commit install --hook-type commit-msg
```
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ check:
@${ACTIVATE} ruff format --check
@$(MAKE) doc8
@echo "-> Run ABOUT files validation"
@${ACTIVATE} about check --exclude .venv/ --exclude scanpipe/tests/ .
@${ACTIVATE} python -c "import sys; sys.exit(0 if sys.version_info < (3, 12) else 1)" && \
about check --exclude .venv/ --exclude scanpipe/tests/ . || \
echo "Skipping ABOUT files validation on Python 3.12+ (distutils missing)"

check-deploy:
@echo "-> Check Django deployment settings"
Expand Down
10 changes: 10 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,13 @@ max-complexity = 10
"**/test_spdx.py*" = ["S101"]
# Allow complexity in management commands
"scanpipe/management/commands/*" = ["C901"]

[tool.commitizen]
name = "cz_conventional_commits"
version = "36.1.0"
tag_format = "v$version"
version_files = [
"scancodeio/__init__.py",
"pyproject.toml:version"
]

13 changes: 13 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"packages": {
".": {
"release-type": "python",
"package-name": "scancodeio",
"version-file": "scancodeio/__init__.py",
"extra-files": [
"pyproject.toml"
]
}
},
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
}
4 changes: 4 additions & 0 deletions scancodeio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
from contextlib import suppress
from pathlib import Path

# This import is required to shim distutils on Python 3.12+ for dependencies
# that rely on it (e.g., python-inspector, aboutcode-toolkit).
if sys.version_info >= (3, 12):
import setuptools # noqa
import git

VERSION = "36.1.0"
Expand Down
Loading