diff --git a/.github/workflows/py-tests.yaml b/.github/workflows/py-tests.yaml index 806ef288..446590bc 100644 --- a/.github/workflows/py-tests.yaml +++ b/.github/workflows/py-tests.yaml @@ -1,36 +1,60 @@ -# 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/ \ No newline at end of file +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: + # might not be needed + # if: github.repository == 'nrel/fastsim' + 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: Python unit tests + run: | + pip install -e ".[dev]" && pytest -v python/fastsim/tests/ + pytest -v python/fastsim/demos/ + + # 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) \ No newline at end of file diff --git a/.github/workflows/rust-tests.yaml b/.github/workflows/rust-tests.yaml index 09896688..ae30df36 100644 --- a/.github/workflows/rust-tests.yaml +++ b/.github/workflows/rust-tests.yaml @@ -1,42 +1,49 @@ -# 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 -# # 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 }} - -# # 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 \ No newline at end of file +name: tests + +on: + push: + branches: [fastsim-2, fastsim-3] + paths: + - "rust/**" + pull_request: + paths: + - "rust/**" + 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 }} + + # 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 + + # in altrios, also includes python tests here, not sure I + # understand what added benefit this gives \ No newline at end of file diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index fa0d63eb..41e11750 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -1,48 +1,44 @@ -name: tests - -on: - push: - branches: [fastsim-2, fastsim-3] - pull_request: - workflow_dispatch: - -jobs: - test: - # 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: - # - ${{ if eq(github.repository, 'NREL/fastsim') }}: - - 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/') }} - # if: ${{ 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/')) }} - # if: ${{ 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/ \ No newline at end of file +# name: tests + +# on: +# push: +# branches: [fastsim-2, fastsim-3] +# pull_request: +# workflow_dispatch: + +# jobs: +# test: +# 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 +# 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/ \ No newline at end of file diff --git a/.github/workflows/wheels.yaml b/.github/workflows/wheels.yaml index f93930e9..7806f23c 100644 --- a/.github/workflows/wheels.yaml +++ b/.github/workflows/wheels.yaml @@ -9,10 +9,11 @@ on: jobs: call-tests: - uses: nrel/fastsim/.github/workflows/tests.yaml@main + uses: nrel/fastsim/.github/workflows/py-tests.yaml@main # 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 }} + needs: call-tests strategy: fail-fast: true matrix: