From acb1e5898057d52a56ac6921970d5dde4e666fee Mon Sep 17 00:00:00 2001 From: Elton Cardoso do Nascimento <43186596+EltonCN@users.noreply.github.com> Date: Sun, 1 Dec 2024 18:47:52 -0300 Subject: [PATCH] Test reusable test workflow --- .github/workflows/test.yml | 35 ++++----------------------- .github/workflows/test_inner.yml | 41 ++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 30 deletions(-) create mode 100644 .github/workflows/test_inner.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4ce7617..b93d454 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,10 +15,10 @@ jobs: os: [ubuntu-latest, windows-latest] python-version: ["3.10", "3.11", "3.12"] + services: # Label used to access the service container redis: - if: runner.os == 'Linux' # Docker Hub image image: redis # Set health checks to wait until redis has started @@ -27,36 +27,11 @@ jobs: --health-interval 10s --health-timeout 5s --health-retries 5 - ports: - # Maps port 6379 on service container to the host - - 6379:6379 - steps: - - uses: actions/checkout@v4 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - - name: Install dependencies - run: | - python3 -m pip install --upgrade pip - python3 -m pip install pytest - python3 -m pip install pytest-cov - python3 -m pip install -e .[tests,gym,memory_storage] - - - name: Tests - run: | - pytest --cov=cst_python --cov-report json - shell: bash - - - if: ${{matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'}} - name: Upload coverage report - uses: actions/upload-artifact@v4 - with: - name: coverage_report - path: coverage.json + - uses: ./.github/workflows/test_inner.yml + with: + os: ${{ matrix.os }} + python-version: ${{ matrix.python-version }} coverage-check: runs-on: ubuntu-latest diff --git a/.github/workflows/test_inner.yml b/.github/workflows/test_inner.yml new file mode 100644 index 0000000..83cc1e2 --- /dev/null +++ b/.github/workflows/test_inner.yml @@ -0,0 +1,41 @@ +name: Test inner +run-name: ${{ github.actor }} is testing out GitHub Actions 🚀 +on: + workflow_call: + inputs: + os: + required: true + type: string + python-version: + required: true + type: string +jobs: + Explore-GitHub-Actions: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Set up Python ${{inputs.python-version}} + uses: actions/setup-python@v2 + with: + python-version: ${{inputs.python-version}} + + - name: Install dependencies + run: | + python3 -m pip install --upgrade pip + python3 -m pip install pytest + python3 -m pip install pytest-cov + python3 -m pip install -e .[tests,gym] + + - name: Tests + run: | + pytest --cov=cst_python --cov-report json + shell: bash + + - if: ${{inputs.os == 'ubuntu-latest' && inputs.python-version == '3.12'}} + name: Upload coverage report + uses: actions/upload-artifact@v4 + with: + name: coverage_report + path: coverage.json +