Run Tests triggered by branch master or fyellin #249
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run Tests | |
run-name: Run Tests triggered by ${{ github.ref_type }} ${{ github.ref_name }} or ${{ github.triggering_actor }} | |
on: | |
workflow_dispatch: | |
pull_request: | |
branches: [ master ] | |
push: | |
branches: [ master ] | |
schedule: | |
- cron: "20 11 * * 0" | |
jobs: | |
test: | |
name: Test cspyce | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ] | |
fail-fast: false | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install -r requirements.txt | |
- name: Cache CSPICE source code | |
uses: actions/cache@v3 | |
env: | |
cache-name: cspice-source-code | |
with: | |
path: cspice | |
# If setup.py is modified, we want to invalidate the cache. It means that there | |
# has been some change to the build process (a new Spice version??) and we want | |
# to make sure new sources are pulled. | |
key: ${{ matrix.os }}-${{ runner.arch }}-${{ env.cache-name }}-${{ hashFiles('setup.py') }} | |
- name: Generate cspyce | |
run: | | |
python setup.py generate | |
- name: Determine compiler version for non-Windows | |
if: matrix.os != 'windows-latest' | |
run: | | |
gcc --version > compiler-version.txt | |
cat compiler-version.txt | |
- name: Determine compiler version for Windows | |
if: matrix.os == 'windows-latest' | |
# We ask Python what it uses as the compiler. I can't find anything simpler. | |
run: | | |
python3 -c 'import distutils.ccompiler as cc; x = cc.new_compiler(); x.initialize(); print(x.cc)' > compiler-version.txt | |
cat compiler-version.txt | |
- name: Cache libraries | |
id: cache-libraries | |
uses: actions/cache@v3 | |
env: | |
cache-name: cspice-libraries | |
with: | |
path: build/ | |
# We need to rebuild the cspice library if the source files have changed, | |
# if there is some change in the build process, or if the compiler version | |
# has changed. | |
key: ${{ matrix.os }}-${{ runner.arch }}-${{ matrix.python-version }}-${{ env.cache-name }}-${{ hashFiles('setup.py', 'compiler-version.txt', 'cspice/**/*') }} | |
- name: Compile C libraries | |
if: ${{ steps.cache-libraries.outputs.cache-hit != 'true' }} | |
run: | | |
python setup.py build_clib | |
- name: Build extensions | |
run: | | |
python setup.py build_ext --inplace | |
- name: Install cspyce | |
run: | | |
python -m pip install . | |
- name: Test with coverage | |
run: | | |
pytest -v -rA --cov=./ --cov-report=xml | |
- name: Upload coverage report to codecov | |
uses: codecov/codecov-action@v3 | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
with: | |
verbose: true |