From ae9428196cd7f107a1d48b486e31711b852c9ec8 Mon Sep 17 00:00:00 2001 From: Robin Steuteville Date: Fri, 23 Feb 2024 14:08:11 -0700 Subject: [PATCH] testing py-tests --- .github/workflows/py-tests.yaml | 135 +++++++++++++++++++++----------- 1 file changed, 91 insertions(+), 44 deletions(-) diff --git a/.github/workflows/py-tests.yaml b/.github/workflows/py-tests.yaml index 63d4aa5e..0aeecf9d 100644 --- a/.github/workflows/py-tests.yaml +++ b/.github/workflows/py-tests.yaml @@ -2,27 +2,12 @@ name: tests on: push: - branches: [fastsim-2, fastsim-3] - # paths: - # - "python/**" - # - "rust/**" + branches: [fastsim-2, fastsim-3] pull_request: - # paths: - # - "python/**" - # - "rust/**" workflow_dispatch: - # workflow_call: jobs: - # call-rust-tests: - # uses: nrel/fastsim/.github/workflows/rust-tests.yaml@main test: - # needs: call-rust-tests - # add in if first step works - # if: ${{ github.repository == 'nrel/fastsim' }} - # or - # if: github.repository == 'nrel/fastsim' - runs-on: ubuntu-latest strategy: @@ -32,32 +17,94 @@ jobs: 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 }} - -# not sure if this is needed if I'm only running python tests - - name: install rust - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - - name: Rust unit tests - run: | - cd rust/ && cargo test - - # in altrios, also includes Rust tests here -- but I think this would mean - # Rust and Python tests are always run (so, even if only python code is - # modified) - - - name: Python unit tests - run: | - pip install -e ".[dev]" && pytest -v python/fastsim/tests/ - pytest -v python/fastsim/demos/ \ No newline at end of file + - 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 + if: ${{ github.repository == 'nrel/fastsim' && contains(github.event.pull_request.changed_files, 'rust/') }} + run: | + cd rust/ && cargo test + + - name: Python unit tests + if: ${{ github.repository == 'nrel/fastsim' && (contains(github.event.pull_request.changed_files, 'python/') || contains(github.event.pull_request.changed_files, 'rust/')) }} + run: | + pip install -e ".[dev]" && pytest -v python/fastsim/tests/ + pytest -v python/fastsim/demos/ + + +################################ +# name: tests + +# on: +# push: +# branches: [fastsim-2, fastsim-3] +# # paths: +# # - "python/**" +# # - "rust/**" +# pull_request: +# # paths: +# # - "python/**" +# # - "rust/**" +# workflow_dispatch: +# # workflow_call: + +# jobs: +# # call-rust-tests: +# # uses: nrel/fastsim/.github/workflows/rust-tests.yaml@main +# test: +# # needs: call-rust-tests +# # add in if first step works +# # if: ${{ github.repository == 'nrel/fastsim' }} +# # or +# # 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 }} + +# # not sure if this is needed if I'm only running python tests +# - name: install rust +# uses: actions-rs/toolchain@v1 +# with: +# profile: minimal +# toolchain: stable +# override: true + +# - name: Rust unit tests +# run: | +# cd rust/ && cargo test + +# # in altrios, also includes Rust tests here -- but I think this would mean +# # Rust and Python tests are always run (so, even if only python code is +# # modified) + +# - name: Python unit tests +# run: | +# pip install -e ".[dev]" && pytest -v python/fastsim/tests/ +# pytest -v python/fastsim/demos/ \ No newline at end of file