Skip to content

Commit

Permalink
Add basic GitHub CI
Browse files Browse the repository at this point in the history
Signed-off-by: Cristian Le <[email protected]>
  • Loading branch information
LecrisUT committed Nov 6, 2023
1 parent 87e2e08 commit 8d12993
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CI

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

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
pre-commit:
uses: ./.github/workflows/step_pre-commit.yaml

tests:
needs: [ pre-commit ]
uses: ./.github/workflows/step_test.yaml

pass:
needs: [ pre-commit, tests ]
runs-on: ubuntu-latest
steps:
- name: Check all CI jobs
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
if: always()
50 changes: 50 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: release
run-name: Release

on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+"

jobs:
tests:
uses: ./.github/workflows/step_test.yaml
pypi-wheel:
needs: [ tests ]
uses: ./.github/workflows/step_build-wheel.yaml
upload_pypi:
name: Upload to PyPI repository
needs: [ tests, pypi-wheel ]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/spglib/
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- name: Publish package to TestPyPI
if: ${{ contains(github.ref, 'rc') }}
# TODO: Maybe we can move this to main PyPI since it is marked rc
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository_url: https://test.pypi.org/legacy/
- name: Publish package to PyPI
if: ${{ !contains(github.ref, 'rc') }}
uses: pypa/gh-action-pypi-publish@release/v1
release:
needs: [ upload_pypi ]
name: Create release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: softprops/action-gh-release@v1
with:
name: Spglib ${{ github.ref_name }}
draft: true
prerelease: ${{ contains(github.ref, 'rc') }}
generate_release_notes: true
19 changes: 19 additions & 0 deletions .github/workflows/step_pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: pre-commit
run-name: Run pre-commits

on:
workflow_call:

permissions:
contents: read

jobs:
pre-commit:
name: Check pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: 3.x
- uses: pre-commit/[email protected]
49 changes: 49 additions & 0 deletions .github/workflows/step_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: test
run-name: Run tests

on:
workflow_call:

permissions:
contents: read

jobs:
tests:
name: Check ${{ matrix.toolchain }} toolchain
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
container: ${{ !matrix.os && 'ghcr.io/lecrisut/dev-env:main' || '' }}
continue-on-error: ${{ matrix.experimental || false }}
strategy:
fail-fast: false
matrix:
toolchain: [ gcc, llvm, intel, windows, macos ]
include:
- os: windows-latest
toolchain: windows
- os: macos-11
toolchain: macos
steps:
- name: Enable msvc toolchain on windows
uses: ilammy/msvc-dev-cmd@v1
if: contains(matrix.os, 'windows')
- name: Activate Intel compilers
run: |
source /opt/intel/oneapi/setvars.sh
printenv >> $GITHUB_ENV
echo $PATH >> $GITHUB_PATH
if: matrix.toolchain == 'intel'
- uses: actions/checkout@v4
- uses: lukka/get-cmake@latest
- name: Run CMake configuration for ${{ matrix.toolchain }} toolchain
uses: lukka/[email protected]
with:
workflowPreset: "${{ matrix.toolchain }}-ci"
pass:
needs: [ tests ]
runs-on: ubuntu-latest
steps:
- name: Check test jobs
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
if: always()

0 comments on commit 8d12993

Please sign in to comment.