From c65367a6ed5bb72195266ed5fa26b59d06673311 Mon Sep 17 00:00:00 2001 From: Alessandro Palmas Date: Sat, 29 Jul 2023 15:10:20 -0400 Subject: [PATCH 1/7] Add installation test CICD, pin ubuntu image, add python env controlled setup, add packages pre-installation --- .github/workflows/docs-rebuild.yaml | 2 +- .github/workflows/images.yaml | 10 ++-- .github/workflows/installation_tests.yaml | 71 +++++++++++++++++++++++ .github/workflows/release.yaml | 4 +- .github/workflows/test.yaml | 4 +- .github/workflows/test_agents.yaml | 2 + setup.py | 2 +- 7 files changed, 87 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/installation_tests.yaml diff --git a/.github/workflows/docs-rebuild.yaml b/.github/workflows/docs-rebuild.yaml index 826d7265..0a6415ba 100644 --- a/.github/workflows/docs-rebuild.yaml +++ b/.github/workflows/docs-rebuild.yaml @@ -1,4 +1,4 @@ -name: docs-rebuild-deploy +name: Documentation build & deploy trigger on: push: diff --git a/.github/workflows/images.yaml b/.github/workflows/images.yaml index 1f605d1c..a8a0c9bb 100644 --- a/.github/workflows/images.yaml +++ b/.github/workflows/images.yaml @@ -1,3 +1,5 @@ +name: Dependencies images + on: push: tags: @@ -10,7 +12,7 @@ on: jobs: generate-matrix: name: Generate build matrix - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 outputs: matrix: ${{ steps.set-matrix.outputs.matrix }} steps: @@ -22,7 +24,7 @@ jobs: build-and-push-arena-images: needs: [generate-matrix] - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 if: ${{ needs.generate-matrix.outputs.matrix != '[]' }} strategy: fail-fast: true @@ -31,7 +33,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Login to GHCR uses: docker/login-action@v2 @@ -76,7 +78,7 @@ jobs: build-and-push-agents-images: if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') needs: [build-and-push-arena-images] - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - name: Build and Push Agents Images run: | diff --git a/.github/workflows/installation_tests.yaml b/.github/workflows/installation_tests.yaml new file mode 100644 index 00000000..ec75135f --- /dev/null +++ b/.github/workflows/installation_tests.yaml @@ -0,0 +1,71 @@ +name: Installation tests + +on: + push: + tags: + - "v*.*.*" + branches: + - main + pull_request: {} + schedule: + - cron: '30 2 * * *' + +jobs: + installation-tests: + runs-on: ubuntu-22.04 + strategy: + matrix: + python-version: ['3.7', '3.8', '3.9', '3.10'] + installation-option: ['basic', 'stable-baselines', 'stable-baselines3', 'ray-rllib'] + python-packages-version: ['default', 'latest'] + + steps: + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Setup environment configuration (default or latest) + run: | + if [ "${{ matrix.python-packages-version }}" == 'latest' ]; then + python3 -m pip install -U pip + python3 -m pip install -U setuptools + fi + pip list + + - name: Pre-install packages needed because of various deprecations deprecation + run: | + python3 -m pip install -U wheel # Deprecated setup.py installation need to move to pyproject.toml + python3 -m pip install wheel==0.38.4 # Deprecated format of gym==0.21 setup.py + python3 -m pip install setuptools==66.0.0 # Deprecated format of gym==0.21 setup.py + pip list + + - name: Define Package Path + id: set_package_path + run: | + if [ "${{ github.event_name }}" == "schedule" ]; then + echo "package_path=diambra-arena" >> "$GITHUB_ENV" + else + echo "package_path=." >> "$GITHUB_ENV" + fi + + - name: Checkout Main Branch and Install Package + if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) + uses: actions/checkout@v3 + + - name: Checkout Pull Request Branch and Install Package + if: github.event_name == 'pull_request' + uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.ref }} + + - name: Install Package via pip + if: ( ( ( matrix.installation-option == 'stable-baselines' || matrix.installation-option == 'basic' ) && matrix.python-version == '3.7' ) || + ( matrix.installation-option != 'stable-baselines' && matrix.python-version != '3.7' ) ) + run: | + if [ "${{ matrix.installation-option }}" == "basic" ]; then + pip install ${{ env.package_path }} + else + pip install ${{ env.package_path }}[${{ matrix.installation-option }}] + fi + pip list diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index d31a09c9..b69e3db7 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,3 +1,5 @@ +name: Python package Pypi release + on: push: tags: @@ -8,7 +10,7 @@ on: jobs: release: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index a71e673f..c06358bf 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,9 +1,11 @@ +name: DIAMBRA Arena tests + on: pull_request: {} jobs: test: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 diff --git a/.github/workflows/test_agents.yaml b/.github/workflows/test_agents.yaml index e3abcf93..52bece15 100644 --- a/.github/workflows/test_agents.yaml +++ b/.github/workflows/test_agents.yaml @@ -1,3 +1,5 @@ +name: DIAMBRA Agents tests + on: pull_request: {} diff --git a/setup.py b/setup.py index e35f0fed..b0fa9761 100644 --- a/setup.py +++ b/setup.py @@ -32,7 +32,7 @@ install_requires=[ 'pip>=21', 'importlib-metadata<=4.12.0; python_version <= "3.7"', # problem with gym for importlib-metadata==5.0.0 and python <=3.7 - 'setuptools<=66.0.0', # Required until we can upgrade to gym >= 0.22.0 + 'setuptools', 'distro>=1', 'gym<=0.21.0', 'inputs', From 7cfe942603d554e933678918faffeba3c76900de Mon Sep 17 00:00:00 2001 From: Alessandro Palmas Date: Sun, 30 Jul 2023 11:58:56 -0400 Subject: [PATCH 2/7] Adding context specific tests --- .github/workflows/test.yaml | 39 +++++++++++++++++-------- .github/workflows/test_main_branch.yaml | 16 ++++++++++ 2 files changed, 43 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/test_main_branch.yaml diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index c06358bf..405c7d61 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,20 +1,35 @@ -name: DIAMBRA Arena tests +name: Reusable Arena unit tests on: - pull_request: {} + workflow_call: + inputs: + arena-branch: + required: true + type: string jobs: - test: + reusable-arena-unit-tests: + name: Reusable Arena unit tests runs-on: ubuntu-22.04 + strategy: + matrix: + python-version: ['3.7', '3.8', '3.9', '3.10'] steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 with: - python-version: "3.x" - - run: python3 -m pip install wheel==0.38.4 + python-version: ${{ matrix.python-version }} + - name: Pre-install pinned packages for deprecations + run: python3 -m pip install wheel==0.38.4 setuptools==66.0.0 + - name: Checkout target branch + uses: actions/checkout@v3 + with: + ref: "${{ inputs.arena-branch }}" - run: python3 -m pip install .["tests"] - - run: pytest tests/test_gym_settings.py - - run: pytest tests/test_wrappers_settings.py - - run: pytest tests/test_recording_settings.py - - run: pytest tests/test_random.py - - run: pytest tests/test_speed.py + - name: Run tests + run: | + pytest tests/test_gym_settings.py + pytest tests/test_wrappers_settings.py + pytest tests/test_recording_settings.py + pytest tests/test_random.py + pytest tests/test_speed.py diff --git a/.github/workflows/test_main_branch.yaml b/.github/workflows/test_main_branch.yaml new file mode 100644 index 00000000..6b32bfbf --- /dev/null +++ b/.github/workflows/test_main_branch.yaml @@ -0,0 +1,16 @@ +name: Main branch tests + +on: + #push: + # branches: + # - main + #schedule: + # - cron: '30 2 * * *' + pull_request: + +jobs: + arena-unit-tests: + name: Arena unit tests + uses: ./.github/workflows/test.yaml + with: + arena-branch: 'main' \ No newline at end of file From 5c5b74110977fc36142d65af4323dd2566d784f7 Mon Sep 17 00:00:00 2001 From: Alessandro Palmas Date: Sun, 30 Jul 2023 12:12:42 -0400 Subject: [PATCH 3/7] Added agents tests --- .../workflows/reusable_agents_unit_tests.yaml | 16 ++++++++++++ ...st.yaml => reusable_arena_unit_tests.yaml} | 25 +++++++++++-------- .github/workflows/test_agents.yaml | 11 -------- .github/workflows/test_main_branch.yaml | 9 +++++-- 4 files changed, 38 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/reusable_agents_unit_tests.yaml rename .github/workflows/{test.yaml => reusable_arena_unit_tests.yaml} (52%) delete mode 100644 .github/workflows/test_agents.yaml diff --git a/.github/workflows/reusable_agents_unit_tests.yaml b/.github/workflows/reusable_agents_unit_tests.yaml new file mode 100644 index 00000000..b249667e --- /dev/null +++ b/.github/workflows/reusable_agents_unit_tests.yaml @@ -0,0 +1,16 @@ +name: Reusable agents unit tests + +on: + workflow_call: + inputs: + arena_branch: + required: true + type: string + +jobs: + reusable_agents_unit_tests: + name: Reusable agents unit tests + uses: diambra/agents/.github/workflows/reusable-test.yaml@main + with: + arena_requirement_specifier: 'git+https://github.com/diambra/arena.git@$${{ inputs.arena_branch }}#egg=' + agents_ref: 'main' diff --git a/.github/workflows/test.yaml b/.github/workflows/reusable_arena_unit_tests.yaml similarity index 52% rename from .github/workflows/test.yaml rename to .github/workflows/reusable_arena_unit_tests.yaml index 405c7d61..f5ec8107 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/reusable_arena_unit_tests.yaml @@ -1,31 +1,36 @@ -name: Reusable Arena unit tests +name: Reusable arena unit tests on: workflow_call: inputs: - arena-branch: + arena_branch: required: true type: string jobs: - reusable-arena-unit-tests: - name: Reusable Arena unit tests + reusable_arena_unit_tests: + name: Reusable arena unit tests runs-on: ubuntu-22.04 strategy: matrix: - python-version: ['3.7', '3.8', '3.9', '3.10'] + python_version: ['3.7', '3.8', '3.9', '3.10'] steps: - - name: Set up Python ${{ matrix.python-version }} + - name: Set up Python ${{ matrix.python_version }} uses: actions/setup-python@v4 with: - python-version: ${{ matrix.python-version }} + python_version: ${{ matrix.python_version }} - name: Pre-install pinned packages for deprecations - run: python3 -m pip install wheel==0.38.4 setuptools==66.0.0 + run: | + python3 -m pip install wheel==0.38.4 setuptools==66.0.0 + pip list - name: Checkout target branch uses: actions/checkout@v3 with: - ref: "${{ inputs.arena-branch }}" - - run: python3 -m pip install .["tests"] + ref: "${{ inputs.arena_branch }}" + - name: Install tests dependencies + run: | + python3 -m pip install .["tests"] + pip list - name: Run tests run: | pytest tests/test_gym_settings.py diff --git a/.github/workflows/test_agents.yaml b/.github/workflows/test_agents.yaml deleted file mode 100644 index 52bece15..00000000 --- a/.github/workflows/test_agents.yaml +++ /dev/null @@ -1,11 +0,0 @@ -name: DIAMBRA Agents tests - -on: - pull_request: {} - -jobs: - test: - uses: diambra/agents/.github/workflows/reusable-test.yaml@main - with: - arena_requirement_specifier: 'git+https://github.com/diambra/arena.git@${{ github.ref }}#egg=' - agents_ref: 'main' diff --git a/.github/workflows/test_main_branch.yaml b/.github/workflows/test_main_branch.yaml index 6b32bfbf..6b79a405 100644 --- a/.github/workflows/test_main_branch.yaml +++ b/.github/workflows/test_main_branch.yaml @@ -11,6 +11,11 @@ on: jobs: arena-unit-tests: name: Arena unit tests - uses: ./.github/workflows/test.yaml + uses: ./.github/workflows/reusable_arena_unit_tests.yaml with: - arena-branch: 'main' \ No newline at end of file + arena_branch: 'main' + agents-unit-tests: + name: Agents unit tests + uses: ./.github/workflows/reusable_agents_unit_tests.yaml + with: + arena_branch: 'main' \ No newline at end of file From 7a7b98f8525fc3bb9996f4a76fc556d440221b85 Mon Sep 17 00:00:00 2001 From: Alessandro Palmas Date: Sun, 30 Jul 2023 12:22:43 -0400 Subject: [PATCH 4/7] Fix python version --- .github/workflows/reusable_arena_unit_tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable_arena_unit_tests.yaml b/.github/workflows/reusable_arena_unit_tests.yaml index f5ec8107..b0fea8dd 100644 --- a/.github/workflows/reusable_arena_unit_tests.yaml +++ b/.github/workflows/reusable_arena_unit_tests.yaml @@ -18,7 +18,7 @@ jobs: - name: Set up Python ${{ matrix.python_version }} uses: actions/setup-python@v4 with: - python_version: ${{ matrix.python_version }} + python-version: ${{ matrix.python_version }} - name: Pre-install pinned packages for deprecations run: | python3 -m pip install wheel==0.38.4 setuptools==66.0.0 From e0865c9ca31b18736dcf3303ba0c3c5005c69bab Mon Sep 17 00:00:00 2001 From: Alessandro Palmas Date: Sun, 30 Jul 2023 12:36:41 -0400 Subject: [PATCH 5/7] Fix branch in agents --- .github/workflows/reusable_agents_unit_tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable_agents_unit_tests.yaml b/.github/workflows/reusable_agents_unit_tests.yaml index b249667e..999ea9e1 100644 --- a/.github/workflows/reusable_agents_unit_tests.yaml +++ b/.github/workflows/reusable_agents_unit_tests.yaml @@ -12,5 +12,5 @@ jobs: name: Reusable agents unit tests uses: diambra/agents/.github/workflows/reusable-test.yaml@main with: - arena_requirement_specifier: 'git+https://github.com/diambra/arena.git@$${{ inputs.arena_branch }}#egg=' + arena_requirement_specifier: 'git+https://github.com/diambra/arena.git@${{ inputs.arena_branch }}#egg=' agents_ref: 'main' From fb0da59dbe47a60289c7010a8ba92ec8af20e1a5 Mon Sep 17 00:00:00 2001 From: Alessandro Palmas Date: Sun, 30 Jul 2023 13:17:48 -0400 Subject: [PATCH 6/7] Add installation test as reusable ones --- ...=> reusable_arena_installation_tests.yaml} | 35 +++++++++---------- .../workflows/reusable_arena_unit_tests.yaml | 5 +++ .github/workflows/test_main_branch.yaml | 6 ++++ 3 files changed, 27 insertions(+), 19 deletions(-) rename .github/workflows/{installation_tests.yaml => reusable_arena_installation_tests.yaml} (75%) diff --git a/.github/workflows/installation_tests.yaml b/.github/workflows/reusable_arena_installation_tests.yaml similarity index 75% rename from .github/workflows/installation_tests.yaml rename to .github/workflows/reusable_arena_installation_tests.yaml index ec75135f..14e58334 100644 --- a/.github/workflows/installation_tests.yaml +++ b/.github/workflows/reusable_arena_installation_tests.yaml @@ -1,17 +1,18 @@ -name: Installation tests +name: Reusable arena installation tests on: - push: - tags: - - "v*.*.*" - branches: - - main - pull_request: {} - schedule: - - cron: '30 2 * * *' + workflow_call: + inputs: + arena_branch: + required: true + type: string + package: + required: false + type: string jobs: - installation-tests: + reusable_arena_installation_tests: + name: Reusable arena installation tests runs-on: ubuntu-22.04 strategy: matrix: @@ -40,24 +41,20 @@ jobs: python3 -m pip install setuptools==66.0.0 # Deprecated format of gym==0.21 setup.py pip list - - name: Define Package Path + - name: Define package path id: set_package_path run: | - if [ "${{ github.event_name }}" == "schedule" ]; then + if [ "${{ inputs.package }}" == "yes" ]; then echo "package_path=diambra-arena" >> "$GITHUB_ENV" else echo "package_path=." >> "$GITHUB_ENV" fi - - name: Checkout Main Branch and Install Package - if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) - uses: actions/checkout@v3 - - - name: Checkout Pull Request Branch and Install Package - if: github.event_name == 'pull_request' + - name: Checkout selected branch + if: ${{ inputs.package }} != "yes" uses: actions/checkout@v3 with: - ref: ${{ github.event.pull_request.head.ref }} + ref: "${{ inputs.arena_branch }}" - name: Install Package via pip if: ( ( ( matrix.installation-option == 'stable-baselines' || matrix.installation-option == 'basic' ) && matrix.python-version == '3.7' ) || diff --git a/.github/workflows/reusable_arena_unit_tests.yaml b/.github/workflows/reusable_arena_unit_tests.yaml index b0fea8dd..3c51bcae 100644 --- a/.github/workflows/reusable_arena_unit_tests.yaml +++ b/.github/workflows/reusable_arena_unit_tests.yaml @@ -14,23 +14,28 @@ jobs: strategy: matrix: python_version: ['3.7', '3.8', '3.9', '3.10'] + steps: - name: Set up Python ${{ matrix.python_version }} uses: actions/setup-python@v4 with: python-version: ${{ matrix.python_version }} + - name: Pre-install pinned packages for deprecations run: | python3 -m pip install wheel==0.38.4 setuptools==66.0.0 pip list + - name: Checkout target branch uses: actions/checkout@v3 with: ref: "${{ inputs.arena_branch }}" + - name: Install tests dependencies run: | python3 -m pip install .["tests"] pip list + - name: Run tests run: | pytest tests/test_gym_settings.py diff --git a/.github/workflows/test_main_branch.yaml b/.github/workflows/test_main_branch.yaml index 6b79a405..734a4296 100644 --- a/.github/workflows/test_main_branch.yaml +++ b/.github/workflows/test_main_branch.yaml @@ -6,6 +6,7 @@ on: # - main #schedule: # - cron: '30 2 * * *' + workflow_dispatch: pull_request: jobs: @@ -17,5 +18,10 @@ jobs: agents-unit-tests: name: Agents unit tests uses: ./.github/workflows/reusable_agents_unit_tests.yaml + with: + arena_branch: 'main' + agents-unit-tests: + name: Arena installation tests + uses: ./.github/workflows/reusable_arena_installation_tests.yaml with: arena_branch: 'main' \ No newline at end of file From 57356ebdb2ad1e23703c2586a8e72207b4c46009 Mon Sep 17 00:00:00 2001 From: Alessandro Palmas Date: Sun, 30 Jul 2023 13:19:06 -0400 Subject: [PATCH 7/7] Fix CICD --- .github/workflows/test_main_branch.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_main_branch.yaml b/.github/workflows/test_main_branch.yaml index 734a4296..e51b0204 100644 --- a/.github/workflows/test_main_branch.yaml +++ b/.github/workflows/test_main_branch.yaml @@ -20,7 +20,7 @@ jobs: uses: ./.github/workflows/reusable_agents_unit_tests.yaml with: arena_branch: 'main' - agents-unit-tests: + arena-installation-tests: name: Arena installation tests uses: ./.github/workflows/reusable_arena_installation_tests.yaml with: