Skip to content

Commit

Permalink
Create Stub Files: Scripts & CI
Browse files Browse the repository at this point in the history
  • Loading branch information
ax3l committed Aug 31, 2023
1 parent 304862c commit 4b872c5
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 6 deletions.
17 changes: 17 additions & 0 deletions .github/update_stub.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
#
# Copyright 2021-2023 The AMReX Community
#
# This script updates the .pyi stub files for documentation and interactive use.
# To run this script, pyAMReX needs to be installed (all dimensions) and importable.
#
# Authors: Axel Huebl
# License: BSD-3-Clause-LBNL
#

# we are in the source directory, .github/
this_dir=$(cd $(dirname $0) && pwd)

pybind11-stubgen --ignore-all-errors -o ${this_dir}/../src/amrex/ amrex.space1d
pybind11-stubgen --ignore-all-errors -o ${this_dir}/../src/amrex/ amrex.space2d
pybind11-stubgen --ignore-all-errors -o ${this_dir}/../src/amrex/ amrex.space3d
34 changes: 34 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: 👑 CI

# This workflow updates the .pyi stub files for documentation and interactive use.

on: [push, pull_request]

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

jobs:
stubs:
name: 🔄 Update Stub Files
uses: ./.github/workflows/stubs.yml
ubuntu:
name: 🐧 Ubuntu
needs: stubs
uses: ./.github/workflows/ubuntu.yml
intel:
name: 🐧 Intel
needs: stubs
uses: ./.github/workflows/intel.yml
hip:
name: 🐧 HIP
needs: stubs
uses: ./.github/workflows/hip.yml
macos:
name: 🍏 macOS
needs: stubs
uses: ./.github/workflows/macos.yml
windows:
name: 🪟 Windows
needs: stubs
uses: ./.github/workflows/windows.yml
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "CodeQL"
name: 🔎 CodeQL

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/hip.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 🐧 HIP

on: [push, pull_request]
on: [workflow_call]

concurrency:
group: ${{ github.ref }}-${{ github.head_ref }}-hip
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/intel.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 🐧 Intel

on: [push, pull_request]
on: [workflow_call]

concurrency:
group: ${{ github.ref }}-${{ github.head_ref }}-intel
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 🍏 macOS

on: [push, pull_request]
on: [workflow_call]

concurrency:
group: ${{ github.ref }}-${{ github.head_ref }}-macos
Expand Down
68 changes: 68 additions & 0 deletions .github/workflows/stubs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: 🔄 Update Stub Files

# This workflow updates the .pyi stub files for documentation and interactive use.

on: [workflow_call]

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

jobs:
# Build and install libamrex as AMReX CMake project
stubs:
name: Stubs
runs-on: ubuntu-22.04
env:
CC: gcc
CXX: g++
CXXFLAGS: "-O1"
OMP_NUM_THREAD: 2

if: github.event.pull_request.draft == false
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# changed files back to the repository.
contents: write

steps:
- uses: actions/checkout@v3
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.head_ref }}

- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.9'

- name: Dependencies
run: .github/workflows/dependencies/dependencies_gcc10.sh

- name: Build & Install
run: |
python3 -m pip install -U pip setuptools wheel
python3 -m pip install -U pip mpi4py pytest pybind11-stubgen pre-commit
cmake -S . -B build -DAMReX_SPACEDIM="1;2;3" -DpyAMReX_IPO=OFF
cmake --build build -j 2 --target pip_install
- name: Update Stubs
run: |
.github/update_stub.sh
- name: Run pre-commit cleanup
run: |
pre-commit run -a
- name: Update Install
run: |
cmake --build build -j 2 --target pip_install
- name: Unit tests
run: |
mpiexec -np 1 python3 -m pytest tests/
- uses: stefanzweifel/git-auto-commit-action@v4
name: Commit Updated Stub Files
with:
commit_message: Update Stub Files
2 changes: 1 addition & 1 deletion .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 🐧 Ubuntu

on: [push, pull_request]
on: [workflow_call]

concurrency:
group: ${{ github.ref }}-${{ github.head_ref }}-linux
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 🪟 Windows

on: [push, pull_request]
on: [workflow_call]

concurrency:
group: ${{ github.ref }}-${{ github.head_ref }}-windows
Expand Down

0 comments on commit 4b872c5

Please sign in to comment.