Skip to content

Commit

Permalink
Modify project Infra (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
fschuch authored Mar 21, 2024
1 parent 4f1c4e0 commit 9d277a0
Show file tree
Hide file tree
Showing 84 changed files with 5,048 additions and 13,790 deletions.
1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
47 changes: 47 additions & 0 deletions .github/workflows/1-prepare-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Prepare a Release

on:
workflow_dispatch:
inputs:
version:
description: "New version to be released"
required: true

jobs:
prepare-for-release:
runs-on: ubuntu-latest
env:
VERSION: ${{ github.event.inputs.version }}
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"

- name: Install Hatch
run: python -m pip install hatch

- name: Update Package Version
run: hatch version "$VERSION"

- name: Update Changelog
run: hatch run changelog:build --yes --version "$VERSION"

- uses: peter-evans/create-pull-request@v4
name: Create Pull Request
id: cpr
with:
commit-message: "Prepared release ${{ github.event.inputs.version }}"
branch: "prepare-release/${{ github.event.inputs.version }}"
title: "Release ${{ github.event.inputs.version }}"
draft: false
delete-branch: true
body: "Automated changes by [prepare_release](.github/workflows/1-prepare-release.yaml) GitHub action."

- name: Show Pull Request info
if: ${{ steps.cpr.outputs.pull-request-number }}
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
50 changes: 50 additions & 0 deletions .github/workflows/2-tag-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Create tag when PR is accepted

on:
pull_request:
branches:
- main
- release/**
types: [closed]

jobs:
create-tag:
if: (github.event.pull_request.merged && startsWith( github.head_ref, 'prepare-release/' ))
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: bluwy/substitute-string-action@v1
name: Get Tag
id: get-tag
with:
_input-text: ${{ github.head_ref }}
prepare-release/: ""

- name: Show tag name
run: echo ${{ steps.get-tag.outputs.result }}

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.12"
cache: "pip"

- name: Install Hatch
run: python -m pip install hatch

- name: Get hatch version
id: get-hatch-version
run: echo "::set-output name=version::$(hatch version)"

- name: Verify tag and hatch version
run: |
if [[ "${{ steps.get-hatch-version.outputs.version }}" != "${{ steps.get-tag.outputs.result }}" ]]; then
echo "Tag name does not match hatch version"
exit 1
fi
- uses: rickstaa/action-create-tag@v1
name: Create and Push Tag
with:
tag: v${{ steps.get-tag.outputs.result }}
23 changes: 23 additions & 0 deletions .github/workflows/check-links.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Check links in Markdown files
on:
schedule:
- cron: "0 0 * * 1" # midnight every Monday
push:
branches: [main]
paths:
- "**/*.md"
pull_request:
paths:
- "**/*.md"

jobs:
check-links:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
use-quiet-mode: "yes"
use-verbose-mode: "yes"
folder-path: "docs/"
file-path: "README.md"
119 changes: 119 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: CI

on:
push:
tags: ["v[0-9]+\\.[0-9]+\\.[0-9]+.*"]
branches:
- main
- release/**
pull_request:
paths:
- .github/workflows/ci.yaml
- hatch.toml
- pyproject.toml
- sonar-project.properties
- tests/**
- xcompact3d_toolbox/**
schedule:
- cron: "0 0 * * 1" # midnight every Monday

concurrency:
group: "${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}"
cancel-in-progress: true

jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install Hatch
run: python -m pip install hatch
- name: Install and Show dependencies
run: hatch run +py=${{ matrix.python-version }} test:pip freeze
- name: Run tests
run: |
hatch run +py=${{ matrix.python-version }} test:extended --cov-report=xml:coverage.${{ matrix.os }}.${{ matrix.python-version }}.xml
- name: Upload coverage data
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.os }}-${{ matrix.python-version }}
path: coverage.*.xml

sonarcloud:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Download coverage data
uses: actions/download-artifact@v4
with:
pattern: coverage-*
merge-multiple: true
- name: Set project version
run: |
if [[ "${{ github.ref_type }}" == "tag" ]]; then
echo "sonar.projectVersion=${{ github.ref }}" >> sonar-project.properties
fi
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

build:
needs: sonarcloud
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"
- name: Install Hatch
run: python -m pip install hatch
- name: Build package
run: hatch build
- uses: actions/upload-artifact@v4
with:
path: dist/*.tar.gz
name: built-sdist
- uses: actions/upload-artifact@v4
with:
path: dist/*.whl
name: built-bdist

release:
needs: build
# upload to PyPI on every tag
if: github.event_name == 'push' && github.ref_type == 'tag' && github.repository == 'fschuch/xcompact3d_toolbox'
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/xcompact3d-toolbox
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- uses: actions/download-artifact@v4
with:
pattern: built-*
path: dist

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

- uses: ncipollo/release-action@v1
with:
draft: true
skipIfReleaseExists: true
generateReleaseNotes: true
57 changes: 57 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Docs

on:
push:
tags: ["v[0-9]+\\.[0-9]+\\.[0-9]+.*"]
branches:
- main
- release/**
pull_request:
paths:
- .github/workflows/docs.yaml
- docs/**
- xcompact3d_toolbox/**
- hatch.toml
- pyproject.toml

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"

- name: Install Hatch
run: python -m pip install hatch

- name: Build the book
run: hatch run docs:build

- uses: actions/upload-artifact@v4
with:
path: build/
name: documentation

deploy:
needs: build
if: github.event_name == 'push' && github.ref_type == 'tag' && github.repository == 'fschuch/xcompact3d_toolbox'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
with:
path: build/
name: documentation

# Push the book's HTML to github-pages
- name: GitHub Pages action
uses: peaceiris/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: build/_build/html
39 changes: 0 additions & 39 deletions .github/workflows/python-package.yml

This file was deleted.

31 changes: 0 additions & 31 deletions .github/workflows/python-publish.yml

This file was deleted.

Loading

0 comments on commit 9d277a0

Please sign in to comment.