From 1bdd6288956fadad0bbf7bb96448f64a1e0cf850 Mon Sep 17 00:00:00 2001 From: Muhammad Yasirroni Date: Wed, 26 Jun 2024 05:28:22 +0700 Subject: [PATCH 01/11] minor build name change --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index df0975f..180e051 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,13 +50,13 @@ jobs: pip install -e ."[dev]" pru - - name: Test package + - name: Run tests id: pytest run: | python3 -m pytest . -c pyproject.toml --cov-report term-missing --cov=src/pru continue-on-error: true - - name: Test package 2 + - name: Run tests with last failed id: pytest2 if: steps.pytest.outcome != 'success' run: | From 8a0867866dc7a73c24c1e29bec20c084aaec291d Mon Sep 17 00:00:00 2001 From: Muhammad Yasirroni Date: Wed, 26 Jun 2024 05:28:54 +0700 Subject: [PATCH 02/11] add auto updater --- .github/scripts/update_requirements.sh | 73 ++++++++++++++++++++++++ .github/workflows/update.yml | 78 ++++++++++++++++++++++++++ 2 files changed, 151 insertions(+) create mode 100644 .github/scripts/update_requirements.sh create mode 100644 .github/workflows/update.yml diff --git a/.github/scripts/update_requirements.sh b/.github/scripts/update_requirements.sh new file mode 100644 index 0000000..4bbc593 --- /dev/null +++ b/.github/scripts/update_requirements.sh @@ -0,0 +1,73 @@ +#!/bin/bash + +set -e + +PYTHON_VERSIONS=("3.7" "3.8" "3.9" "3.10" "3.11" "3.12") +UPDATED_FILES=() +DATE=$(date -u +'%Y-%m-%d') + +# Function to install Python if not already installed +install_python() { + local version="$1" + + if ! command -v python${version} &> /dev/null; then + echo "Python ${version} not found. Installing..." + sudo apt-get update + sudo apt-get install -y python${version} + else + echo "Python ${version} is already installed." + fi +} + +for version in "${PYTHON_VERSIONS[@]}"; do + echo "Processing Python $version" + + # Install Python if not already installed + install_python "$version" + + # Create virtual environment specific to the current Python version + python${version} -m venv "env_${version}" + source "env_${version}/bin/activate" + + # Ensure pip is up-to-date within the virtual environment + pip install --upgrade pip + + # Install pru into the virtual environment + pip install pru + + # Calculate checksums before running pru + minor_version=$(python${version} -c "import sys; print(f'{sys.version_info.minor}')") + checksum_before_single=$(md5sum "pytests/requirements/3_${minor_version}/requirements_single_updated.txt" | cut -d ' ' -f 1) + checksum_before_mix=$(md5sum "pytests/requirements/3_${minor_version}/requirements_mix_updated.txt" | cut -d ' ' -f 1) + + # Run pru to update requirements within the virtual environment + pru -r "pytests/requirements/3_${minor_version}/requirements_single_updated.txt" + pru -r "pytests/requirements/3_${minor_version}/requirements_mix_updated.txt" + + # Calculate checksums after running pru + checksum_after_single=$(md5sum "pytests/requirements/3_${minor_version}/requirements_single_updated.txt" | cut -d ' ' -f 1) + checksum_after_mix=$(md5sum "pytests/requirements/3_${minor_version}/requirements_mix_updated.txt" | cut -d ' ' -f 1) + + # Check if any requirements file was updated + if [ "$checksum_before_single" != "$checksum_after_single" ]; then + UPDATED_FILES+=("pytests/requirements/3_${minor_version}/requirements_single_updated.txt") + fi + if [ "$checksum_before_mix" != "$checksum_after_mix" ]; then + UPDATED_FILES+=("pytests/requirements/3_${minor_version}/requirements_mix_updated.txt") + fi + + # Deactivate the virtual environment + deactivate + # Remove the virtual environment directory + rm -rf "env_${version}" +done + +if [ ${#UPDATED_FILES[@]} -ne 0 ]; then + echo "Requirements updated. Creating pull request." + echo "::set-output name=updated::true" + echo "::set-output name=updated_files::${UPDATED_FILES[*]}" + echo "::set-output name=update_date::$DATE" +else + echo "No requirements updated." + echo "::set-output name=updated::false" +fi diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml new file mode 100644 index 0000000..c60bdd3 --- /dev/null +++ b/.github/workflows/update.yml @@ -0,0 +1,78 @@ +name: Update Requirements + +on: + pull_request: + +jobs: + update: + runs-on: ubuntu-latest + steps: + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.7 + + - name: Check out repository + uses: actions/checkout@v4 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pru + + - name: Determine current branch + id: current_branch + run: echo "CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_ENV + + - name: Run requirements updater script + id: run_pru + run: | + bash .github/scripts/update_requirements.sh + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Configure git + if: steps.run_pru.outputs.updated == 'true' + run: | + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git config --global user.name "github-actions[bot]" + + - name: Create new branch + if: steps.run_pru.outputs.updated == 'true' + run: | + BRANCH_NAME="update-requirements-${GITHUB_RUN_ID}" + git checkout -b $BRANCH_NAME + echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV + echo "DATE=${{ steps.run_pru.outputs.update_date }}" >> $GITHUB_ENV + + - name: Commit changes + if: steps.run_pru.outputs.updated == 'true' + run: | + git add . + git commit -m "Update requirements based on failed tests at $DATE" + env: + DATE: ${{ steps.run_pru.outputs.update_date }} + + - name: Push changes + if: steps.run_pru.outputs.updated == 'true' + run: | + git push origin $BRANCH_NAME + env: + BRANCH_NAME: ${{ env.BRANCH_NAME }} + + - name: Create Pull Request + if: steps.run_pru.outputs.updated == 'true' + uses: peter-evans/create-pull-request@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: | + Update requirements based on failed tests + - Updated files: ${{ steps.run_pru.outputs.updated_files }} + - Date: ${{ steps.run_pru.outputs.update_date }} + branch: update-requirements-${{ github.run_id }} + title: 'Update requirements on ${{ steps.run_pru.outputs.update_date }}' + body: | + This PR updates the following requirements files based on the output of failed tests: + - ${{ steps.run_pru.outputs.updated_files }} + Date of update: ${{ steps.run_pru.outputs.update_date }} + labels: update, automated-pr From 40526a25682a1f85b9d6b50fe863183fcb2b530b Mon Sep 17 00:00:00 2001 From: Muhammad Yasirroni Date: Wed, 26 Jun 2024 05:32:10 +0700 Subject: [PATCH 03/11] skip 3.7 on updater since no python on apt-get --- .github/scripts/update_requirements.sh | 2 +- .github/workflows/update.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/scripts/update_requirements.sh b/.github/scripts/update_requirements.sh index 4bbc593..5c4447c 100644 --- a/.github/scripts/update_requirements.sh +++ b/.github/scripts/update_requirements.sh @@ -2,7 +2,7 @@ set -e -PYTHON_VERSIONS=("3.7" "3.8" "3.9" "3.10" "3.11" "3.12") +PYTHON_VERSIONS=("3.9" "3.10" "3.11" "3.12") UPDATED_FILES=() DATE=$(date -u +'%Y-%m-%d') diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index c60bdd3..6e433c0 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -10,7 +10,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: 3.7 + python-version: 3.8 - name: Check out repository uses: actions/checkout@v4 From e27db77bdec1583aaf5c82d023faec7e627b4924 Mon Sep 17 00:00:00 2001 From: Muhammad Yasirroni Date: Wed, 26 Jun 2024 06:00:40 +0700 Subject: [PATCH 04/11] add deadsnake --- .github/scripts/update_requirements.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/scripts/update_requirements.sh b/.github/scripts/update_requirements.sh index 5c4447c..58b0f3d 100644 --- a/.github/scripts/update_requirements.sh +++ b/.github/scripts/update_requirements.sh @@ -12,6 +12,9 @@ install_python() { if ! command -v python${version} &> /dev/null; then echo "Python ${version} not found. Installing..." + sudo apt update + sudo apt install software-properties-common + sudo add-apt-repository ppa:deadsnakes/ppa sudo apt-get update sudo apt-get install -y python${version} else From a5a32886b58e49a6fd60ddcf685eef5fbdfde491 Mon Sep 17 00:00:00 2001 From: Muhammad Yasirroni Date: Wed, 26 Jun 2024 06:06:34 +0700 Subject: [PATCH 05/11] get-pip if not installed --- .github/scripts/update_requirements.sh | 9 ++++++++- .github/workflows/update.yml | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/scripts/update_requirements.sh b/.github/scripts/update_requirements.sh index 58b0f3d..8c47817 100644 --- a/.github/scripts/update_requirements.sh +++ b/.github/scripts/update_requirements.sh @@ -16,7 +16,7 @@ install_python() { sudo apt install software-properties-common sudo add-apt-repository ppa:deadsnakes/ppa sudo apt-get update - sudo apt-get install -y python${version} + sudo apt-get install -y python${version} python${version}-venv else echo "Python ${version} is already installed." fi @@ -32,6 +32,13 @@ for version in "${PYTHON_VERSIONS[@]}"; do python${version} -m venv "env_${version}" source "env_${version}/bin/activate" + # Install pip using get-pip.py if it's not already installed + if ! command -v pip &> /dev/null; then + curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py + python get-pip.py + rm get-pip.py + fi + # Ensure pip is up-to-date within the virtual environment pip install --upgrade pip diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 6e433c0..82845d4 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -1,4 +1,4 @@ -name: Update Requirements +name: update on: pull_request: From 181a43ab17ef1e751a24d1e823528e7a8d30e134 Mon Sep 17 00:00:00 2001 From: Muhammad Yasirroni Date: Wed, 26 Jun 2024 06:18:41 +0700 Subject: [PATCH 06/11] remove checkout branch --- .github/workflows/update.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 82845d4..41dabfa 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -37,14 +37,6 @@ jobs: git config --global user.email "github-actions[bot]@users.noreply.github.com" git config --global user.name "github-actions[bot]" - - name: Create new branch - if: steps.run_pru.outputs.updated == 'true' - run: | - BRANCH_NAME="update-requirements-${GITHUB_RUN_ID}" - git checkout -b $BRANCH_NAME - echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV - echo "DATE=${{ steps.run_pru.outputs.update_date }}" >> $GITHUB_ENV - - name: Commit changes if: steps.run_pru.outputs.updated == 'true' run: | From c0893a85bbfcae7cf4ac28415b754098aa4c83ff Mon Sep 17 00:00:00 2001 From: Muhammad Yasirroni Date: Wed, 26 Jun 2024 06:19:15 +0700 Subject: [PATCH 07/11] remove git push command --- .github/workflows/update.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 41dabfa..ece8fcd 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -45,13 +45,6 @@ jobs: env: DATE: ${{ steps.run_pru.outputs.update_date }} - - name: Push changes - if: steps.run_pru.outputs.updated == 'true' - run: | - git push origin $BRANCH_NAME - env: - BRANCH_NAME: ${{ env.BRANCH_NAME }} - - name: Create Pull Request if: steps.run_pru.outputs.updated == 'true' uses: peter-evans/create-pull-request@v4 From f7a007e827bf9033fb67fc0fe3457d6f216528a4 Mon Sep 17 00:00:00 2001 From: Muhammad Yasirroni Date: Wed, 26 Jun 2024 06:28:40 +0700 Subject: [PATCH 08/11] not making PR, manual merge --- .github/workflows/update.yml | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index ece8fcd..be93f66 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -37,6 +37,14 @@ jobs: git config --global user.email "github-actions[bot]@users.noreply.github.com" git config --global user.name "github-actions[bot]" + - name: Create new branch + if: steps.run_pru.outputs.updated == 'true' + run: | + BRANCH_NAME="update-requirements-${GITHUB_RUN_ID}" + git checkout -b $BRANCH_NAME + echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV + echo "DATE=${{ steps.run_pru.outputs.update_date }}" >> $GITHUB_ENV + - name: Commit changes if: steps.run_pru.outputs.updated == 'true' run: | @@ -45,19 +53,9 @@ jobs: env: DATE: ${{ steps.run_pru.outputs.update_date }} - - name: Create Pull Request + - name: Push changes if: steps.run_pru.outputs.updated == 'true' - uses: peter-evans/create-pull-request@v4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - commit-message: | - Update requirements based on failed tests - - Updated files: ${{ steps.run_pru.outputs.updated_files }} - - Date: ${{ steps.run_pru.outputs.update_date }} - branch: update-requirements-${{ github.run_id }} - title: 'Update requirements on ${{ steps.run_pru.outputs.update_date }}' - body: | - This PR updates the following requirements files based on the output of failed tests: - - ${{ steps.run_pru.outputs.updated_files }} - Date of update: ${{ steps.run_pru.outputs.update_date }} - labels: update, automated-pr + run: | + git push origin $BRANCH_NAME + env: + BRANCH_NAME: ${{ env.BRANCH_NAME }} From cf6c07fe3110b4bd038e635fb6586074784b9277 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 25 Jun 2024 23:30:57 +0000 Subject: [PATCH 09/11] Update requirements based on failed tests at 2024-06-25 --- pytests/requirements/3_10/requirements_mix_updated.txt | 6 +++--- pytests/requirements/3_10/requirements_single_updated.txt | 2 +- pytests/requirements/3_11/requirements_mix_updated.txt | 6 +++--- pytests/requirements/3_11/requirements_single_updated.txt | 2 +- pytests/requirements/3_12/requirements_mix_updated.txt | 6 +++--- pytests/requirements/3_12/requirements_single_updated.txt | 2 +- pytests/requirements/3_9/requirements_mix_updated.txt | 4 ++-- pytests/requirements/3_9/requirements_single_updated.txt | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/pytests/requirements/3_10/requirements_mix_updated.txt b/pytests/requirements/3_10/requirements_mix_updated.txt index 350ff98..bd57140 100644 --- a/pytests/requirements/3_10/requirements_mix_updated.txt +++ b/pytests/requirements/3_10/requirements_mix_updated.txt @@ -1,4 +1,4 @@ -requests==2.32.2 -numpy==1.26.4 +requests==2.32.3 +numpy==2.0.0 pandas==2.2.2 -scipy==1.13.1 +scipy==1.14.0 diff --git a/pytests/requirements/3_10/requirements_single_updated.txt b/pytests/requirements/3_10/requirements_single_updated.txt index 6e42168..d80d9fc 100644 --- a/pytests/requirements/3_10/requirements_single_updated.txt +++ b/pytests/requirements/3_10/requirements_single_updated.txt @@ -1 +1 @@ -requests==2.32.2 +requests==2.32.3 diff --git a/pytests/requirements/3_11/requirements_mix_updated.txt b/pytests/requirements/3_11/requirements_mix_updated.txt index 350ff98..bd57140 100644 --- a/pytests/requirements/3_11/requirements_mix_updated.txt +++ b/pytests/requirements/3_11/requirements_mix_updated.txt @@ -1,4 +1,4 @@ -requests==2.32.2 -numpy==1.26.4 +requests==2.32.3 +numpy==2.0.0 pandas==2.2.2 -scipy==1.13.1 +scipy==1.14.0 diff --git a/pytests/requirements/3_11/requirements_single_updated.txt b/pytests/requirements/3_11/requirements_single_updated.txt index 6e42168..d80d9fc 100644 --- a/pytests/requirements/3_11/requirements_single_updated.txt +++ b/pytests/requirements/3_11/requirements_single_updated.txt @@ -1 +1 @@ -requests==2.32.2 +requests==2.32.3 diff --git a/pytests/requirements/3_12/requirements_mix_updated.txt b/pytests/requirements/3_12/requirements_mix_updated.txt index 350ff98..bd57140 100644 --- a/pytests/requirements/3_12/requirements_mix_updated.txt +++ b/pytests/requirements/3_12/requirements_mix_updated.txt @@ -1,4 +1,4 @@ -requests==2.32.2 -numpy==1.26.4 +requests==2.32.3 +numpy==2.0.0 pandas==2.2.2 -scipy==1.13.1 +scipy==1.14.0 diff --git a/pytests/requirements/3_12/requirements_single_updated.txt b/pytests/requirements/3_12/requirements_single_updated.txt index 6e42168..d80d9fc 100644 --- a/pytests/requirements/3_12/requirements_single_updated.txt +++ b/pytests/requirements/3_12/requirements_single_updated.txt @@ -1 +1 @@ -requests==2.32.2 +requests==2.32.3 diff --git a/pytests/requirements/3_9/requirements_mix_updated.txt b/pytests/requirements/3_9/requirements_mix_updated.txt index 350ff98..52bc25b 100644 --- a/pytests/requirements/3_9/requirements_mix_updated.txt +++ b/pytests/requirements/3_9/requirements_mix_updated.txt @@ -1,4 +1,4 @@ -requests==2.32.2 -numpy==1.26.4 +requests==2.32.3 +numpy==2.0.0 pandas==2.2.2 scipy==1.13.1 diff --git a/pytests/requirements/3_9/requirements_single_updated.txt b/pytests/requirements/3_9/requirements_single_updated.txt index 6e42168..d80d9fc 100644 --- a/pytests/requirements/3_9/requirements_single_updated.txt +++ b/pytests/requirements/3_9/requirements_single_updated.txt @@ -1 +1 @@ -requests==2.32.2 +requests==2.32.3 From 5cd131a8cf42077d91d3417bd2467206476edfb7 Mon Sep 17 00:00:00 2001 From: Muhammad Yasirroni Date: Wed, 26 Jun 2024 06:36:45 +0700 Subject: [PATCH 10/11] add 3.7 and 3.8 --- .github/scripts/update_requirements.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/update_requirements.sh b/.github/scripts/update_requirements.sh index 8c47817..d5e33f0 100644 --- a/.github/scripts/update_requirements.sh +++ b/.github/scripts/update_requirements.sh @@ -2,7 +2,7 @@ set -e -PYTHON_VERSIONS=("3.9" "3.10" "3.11" "3.12") +PYTHON_VERSIONS=("3.7" "3.8" "3.9" "3.10" "3.11" "3.12") UPDATED_FILES=() DATE=$(date -u +'%Y-%m-%d') From 71edc969544471169d40ff7992e8730b73a7af3f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 25 Jun 2024 23:39:56 +0000 Subject: [PATCH 11/11] Update requirements based on failed tests at 2024-06-25 --- pytests/requirements/3_8/requirements_mix_updated.txt | 2 +- pytests/requirements/3_8/requirements_single_updated.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pytests/requirements/3_8/requirements_mix_updated.txt b/pytests/requirements/3_8/requirements_mix_updated.txt index 8244e5e..d7a8188 100644 --- a/pytests/requirements/3_8/requirements_mix_updated.txt +++ b/pytests/requirements/3_8/requirements_mix_updated.txt @@ -1,4 +1,4 @@ -requests==2.32.2 +requests==2.32.3 numpy==1.24.4 pandas==2.0.3 scipy==1.10.1 diff --git a/pytests/requirements/3_8/requirements_single_updated.txt b/pytests/requirements/3_8/requirements_single_updated.txt index 6e42168..d80d9fc 100644 --- a/pytests/requirements/3_8/requirements_single_updated.txt +++ b/pytests/requirements/3_8/requirements_single_updated.txt @@ -1 +1 @@ -requests==2.32.2 +requests==2.32.3