From 761a927c205c11871841f59b9487b8299ad38b0b Mon Sep 17 00:00:00 2001 From: firefly-cpp Date: Mon, 23 Jan 2023 08:56:52 +0100 Subject: [PATCH] Improve workflows --- .github/workflows/python-app.yml | 36 ---------------------- .github/workflows/test.yml | 53 ++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 36 deletions(-) delete mode 100644 .github/workflows/python-app.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml deleted file mode 100644 index ed1dee6..0000000 --- a/.github/workflows/python-app.yml +++ /dev/null @@ -1,36 +0,0 @@ -# This workflow will install Python dependencies, run tests and lint with a single version of Python -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - -name: FireflyAlgorithm - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up Python 3.9 - uses: actions/setup-python@v2 - with: - python-version: "3.9" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 pytest numpy - 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/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..f6fbc1a --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,53 @@ +name: fireflyalgorithm + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + python-version: ['3.9', '3.10'] + defaults: + run: + shell: bash + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Get full Python version + id: full-python-version + run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") + - name: Install poetry + run: | + curl -sL https://install.python-poetry.org | python - -y + - name: Update path + if: ${{ matrix.os != 'windows-latest' }} + run: echo "$HOME/.local/bin" >> $GITHUB_PATH + - name: Update Windows path + if: ${{ matrix.os == 'windows-latest' }} + run: echo "$APPDATA\Python\Scripts" >> $GITHUB_PATH + - name: Configure poetry + run: poetry config virtualenvs.in-project true + - name: Set up cache + uses: actions/cache@v3 + id: cache + with: + path: .venv + key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }} + - name: Ensure cache is healthy + if: steps.cache.outputs.cache-hit == 'true' + run: timeout 10s poetry run pip --version || rm -rf .venv + - name: Install dependencies + run: poetry install + - name: Run tests + run: poetry run pytest