From f17bb15c70571e2413fba4bb105578eae21615c7 Mon Sep 17 00:00:00 2001 From: Wyatt Stanke Date: Fri, 12 Apr 2024 19:40:58 -0400 Subject: [PATCH] Update GitHub workflows --- .github/workflows/cron_job_tests.yml | 23 ------------- .github/workflows/lint.yml | 7 ++++ .github/workflows/pylint.yml | 22 ------------- .github/workflows/python-app.yml | 35 -------------------- .github/workflows/python-package.yml | 38 --------------------- .github/workflows/run_examples.yml | 34 ++++++++++++------- .github/workflows/stale.yml | 35 +++++++++++++++++--- .github/workflows/stale_issue.yml | 49 ---------------------------- .github/workflows/test.yml | 5 ++- scripts/run_examples.sh | 4 +-- 10 files changed, 65 insertions(+), 187 deletions(-) delete mode 100644 .github/workflows/cron_job_tests.yml delete mode 100644 .github/workflows/pylint.yml delete mode 100644 .github/workflows/python-app.yml delete mode 100644 .github/workflows/python-package.yml delete mode 100644 .github/workflows/stale_issue.yml diff --git a/.github/workflows/cron_job_tests.yml b/.github/workflows/cron_job_tests.yml deleted file mode 100644 index 1292a441..00000000 --- a/.github/workflows/cron_job_tests.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- -name: Run pytest -on: - schedule: - # This will run the job every day at a random minute past the hour - - cron: '0 0 * * *' -jobs: - test: - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.9' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install pytest - pip install swarms - - name: Run tests - run: pytest diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 973ad704..5cd72b1a 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -24,3 +24,10 @@ jobs: - run: pip install ruff - run: ruff format . - run: ruff check --fix . + pylint-lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + - run: pip install pylint + - run: pylint . diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml deleted file mode 100644 index 59eea4f2..00000000 --- a/.github/workflows/pylint.yml +++ /dev/null @@ -1,22 +0,0 @@ ---- -name: Pylint -on: [push] -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ["3.8", "3.9", "3.10"] - steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install pylint - - name: Analysing the code with pylint - run: | - pylint $(git ls-files '*.py') diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml deleted file mode 100644 index f6aef90b..00000000 --- a/.github/workflows/python-app.yml +++ /dev/null @@ -1,35 +0,0 @@ ---- -# This workflow will install Python dependencies, run tests and lint with a single version of Python -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python - -name: Python application -on: - push: - branches: ["master"] - pull_request: - branches: ["master"] -permissions: - contents: read -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Set up Python 3.10 - uses: actions/setup-python@v5 - with: - python-version: "3.10" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 pytest swarms - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest - run: | - pytest diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml deleted file mode 100644 index 943e996a..00000000 --- a/.github/workflows/python-package.yml +++ /dev/null @@ -1,38 +0,0 @@ ---- -# This workflow will install Python dependencies, run tests and lint with a variety of Python versions -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python - -name: Python package -on: - push: - branches: ["master"] - pull_request: - branches: ["master"] -jobs: - build: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - python-version: ["3.7", "3.9", "3.10", "3.11"] - steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install --upgrade swarms - python -m pip install flake8 pytest swarms - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest - run: |- - pytest diff --git a/.github/workflows/run_examples.yml b/.github/workflows/run_examples.yml index 73e5eeb1..685c84c4 100644 --- a/.github/workflows/run_examples.yml +++ b/.github/workflows/run_examples.yml @@ -7,23 +7,33 @@ on: branches: [main] schedule: # Runs at 3:00 AM UTC every day - - cron: '0 3 * * *' + - cron: "0 3 * * *" jobs: run-examples: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: '3.9' - - name: Install dependencies + - name: Install Python + uses: actions/setup-python@v4 + - name: Install Poetry + uses: snok/install-poetry@v1 + - name: Setup a local virtual environment run: | - pip install -r requirements.txt - # Assuming your script might also need pytest and swarms - pip install pytest - pip install swarms + poetry config virtualenvs.create true --local + poetry config virtualenvs.in-project true --local + - uses: actions/cache@v3 + name: Define a cache for the virtual environment + file + with: + path: ./.venv + key: venv-${{ hashFiles('poetry.lock') }} + - name: Install the project dependencies + run: poetry install + - name: Install OpenCV + run: sudo apt-get install python3-opencv + - name: Enter the virtual environment + run: source $VENV - name: Make Script Executable and Run run: |- - chmod +x ./swarms/scripts/run_examples.sh - ./swarms/scripts/run_examples.sh + chmod +x ./scripts/run_examples.sh + ./scripts/run_examples.sh diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index a44aa349..47120202 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -7,7 +7,8 @@ name: Mark stale issues and pull requests on: schedule: - - cron: '26 12 * * *' + # Scheduled to run at 1.30 UTC everyday + - cron: '30 1 * * *' jobs: stale: runs-on: ubuntu-latest @@ -18,7 +19,31 @@ jobs: - uses: actions/stale@v9 with: repo-token: ${{ secrets.GITHUB_TOKEN }} - stale-issue-message: 'Stale issue message' - stale-pr-message: 'Stale pull request message' - stale-issue-label: 'no-issue-activity' - stale-pr-label: 'no-pr-activity' + days-before-issue-stale: 14 + days-before-issue-close: 14 + stale-issue-label: "status:stale" + close-issue-reason: not_planned + any-of-labels: "status:awaiting user response,status:more data needed" + stale-issue-message: > + Marking this issue as stale since it has been open for 14 days with no + activity. This issue will be closed if no further activity occurs. + + close-issue-message: > + This issue was closed because it has been inactive for 28 days. Please + post a new issue if you need further assistance. Thanks! + + days-before-pr-stale: 14 + days-before-pr-close: 14 + stale-pr-label: "status:stale" + stale-pr-message: > + Marking this pull request as stale since it has been open for 14 days + with no activity. This PR will be closed if no further activity occurs. + + close-pr-message: > + This pull request was closed because it has been inactive for 28 days. + Please open a new pull request if you need further assistance. Thanks! + + # Label that can be assigned to issues to exclude them from being marked as stale + exempt-issue-labels: 'override-stale' + # Label that can be assigned to PRs to exclude them from being marked as stale + exempt-pr-labels: "override-stale" diff --git a/.github/workflows/stale_issue.yml b/.github/workflows/stale_issue.yml deleted file mode 100644 index 47120202..00000000 --- a/.github/workflows/stale_issue.yml +++ /dev/null @@ -1,49 +0,0 @@ ---- -# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time. -# -# You can adjust the behavior by modifying this file. -# For more information, see: -# https://github.com/actions/stale -name: Mark stale issues and pull requests -on: - schedule: - # Scheduled to run at 1.30 UTC everyday - - cron: '30 1 * * *' -jobs: - stale: - runs-on: ubuntu-latest - permissions: - issues: write - pull-requests: write - steps: - - uses: actions/stale@v9 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - days-before-issue-stale: 14 - days-before-issue-close: 14 - stale-issue-label: "status:stale" - close-issue-reason: not_planned - any-of-labels: "status:awaiting user response,status:more data needed" - stale-issue-message: > - Marking this issue as stale since it has been open for 14 days with no - activity. This issue will be closed if no further activity occurs. - - close-issue-message: > - This issue was closed because it has been inactive for 28 days. Please - post a new issue if you need further assistance. Thanks! - - days-before-pr-stale: 14 - days-before-pr-close: 14 - stale-pr-label: "status:stale" - stale-pr-message: > - Marking this pull request as stale since it has been open for 14 days - with no activity. This PR will be closed if no further activity occurs. - - close-pr-message: > - This pull request was closed because it has been inactive for 28 days. - Please open a new pull request if you need further assistance. Thanks! - - # Label that can be assigned to issues to exclude them from being marked as stale - exempt-issue-labels: 'override-stale' - # Label that can be assigned to PRs to exclude them from being marked as stale - exempt-pr-labels: "override-stale" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8973c9d5..9cfcd7d4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,5 +1,8 @@ name: Tests -on: [push] +on: + push: + schedule: + - cron: "0 0 * * *" jobs: test: runs-on: ubuntu-latest diff --git a/scripts/run_examples.sh b/scripts/run_examples.sh index f7978058..0f1a0618 100644 --- a/scripts/run_examples.sh +++ b/scripts/run_examples.sh @@ -9,10 +9,10 @@ for f in /swarms/playground/examples/example_*.py; do echo "Skipping ${f} as it ran successfully in a previous run." else # Run the script if not previously successful - if /home/kye/miniconda3/envs/swarms/bin/python "$f" 2>>errors.txt; then + if python "$f" 2>>errors.txt; then echo "(${f}) ran successfully without errors." # Log the successful script execution - echo "$f" >> "$SUCCESS_LOG" + echo "$f" >>"$SUCCESS_LOG" else echo "Error encountered in ${f}. Check errors.txt for details." break