Skip to content

Commit

Permalink
first attempt at creating separate rust and py tests yamls
Browse files Browse the repository at this point in the history
  • Loading branch information
robinsteuteville committed Feb 2, 2024
1 parent 5cb935c commit ec01854
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 32 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/py-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: py-tests

on:
push:
branches: [fastsim-2, fastsim-3]
pull_request:
workflow_dispatch:
workflow_call:

jobs:
test:
# might not be needed
if: github.repository == 'nrel/fastsim'

runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
python-version: ['3.8', '3.9', '3.10']

if: contains(github.event.pull_request.changed_files, 'python/') || contains(github.event.pull_request.changed_files, 'rust/')
env:
PYTHON: ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v3

- name: set up python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Python unit tests
run: |
pip install -e ".[dev]" && pytest -v python/fastsim/tests/
pytest -v python/fastsim/demos/
30 changes: 30 additions & 0 deletions .github/workflows/rust-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: rust-tests

on:
push:
branches: [fastsim-2, fastsim-3]
pull_request:
workflow_dispatch:
workflow_call:

jobs:
test:
# might not be needed
if: github.repository == 'nrel/fastsim'

runs-on: ubuntu-latest

strategy:
fail-fast: true

if: contains(github.event.pull_request.changed_files, 'rust/')
- name: install rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: Rust unit tests
run: |
cd rust/ && cargo test
57 changes: 32 additions & 25 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,45 @@ on:
branches: [fastsim-2, fastsim-3]
pull_request:
workflow_dispatch:
workflow_call:

jobs:
test:
# might not be needed
if: github.repository == 'nrel/fastsim'

runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
python-version: ['3.8', '3.9', '3.10']

env:
PYTHON: ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v3

- name: set up python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: install rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: Rust unit tests
run: |
cd rust/ && cargo test
- name: Python unit tests
run: |
pip install -e ".[dev]" && pytest -v python/fastsim/tests/
pytest -v python/fastsim/demos/
if: contains(github.event.pull_request.changed_files, 'python/') || contains(github.event.pull_request.changed_files, 'rust/')
env:
PYTHON: ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v3

- name: set up python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

if: contains(github.event.pull_request.changed_files, 'rust/')
- name: install rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: Rust unit tests
run: |
cd rust/ && cargo test
if: contains(github.event.pull_request.changed_files, 'python/') || contains(github.event.pull_request.changed_files, 'rust/')
- name: Python unit tests
run: |
pip install -e ".[dev]" && pytest -v python/fastsim/tests/
pytest -v python/fastsim/demos/
19 changes: 12 additions & 7 deletions .github/workflows/wheels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on:
workflow_dispatch:

jobs:
call-tests:
uses: nrel/fastsim/.github/workflows/rust-tests.yaml@main && nrel/fastsim/.github/workflows/py-tests.yaml@main
build:
name: build py3.${{ matrix.python-version }} on ${{ matrix.platform || matrix.os }}
strategy:
Expand Down Expand Up @@ -42,13 +44,13 @@ jobs:
- run: rustup target add aarch64-apple-darwin
if: matrix.os == 'macos'

- name: run cargo tests
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: cd rust/ && cargo test
# - name: run cargo tests
# uses: actions-rs/toolchain@v1
# with:
# profile: minimal
# toolchain: stable
# override: true
# - run: cd rust/ && cargo test

- name: set up python
uses: actions/setup-python@v4
Expand Down Expand Up @@ -105,6 +107,9 @@ jobs:
# rustup override set nightly-i686-pc-windows-msvc &&
# rustup show

#somewhere around this point in the altrios file, theres a if: github.repository
#== 'nrel/altrios', not sure if that is needed here, the code surrounding the if
#statement isn't included here
- name: list dist files
run: ${{ matrix.ls || 'ls -lh' }} dist/

Expand Down

0 comments on commit ec01854

Please sign in to comment.