From e971bd2dbc63e6b7d78a6f65ed7ad9bf8c679bc2 Mon Sep 17 00:00:00 2001 From: Shay Margolis Date: Thu, 17 Apr 2025 12:29:38 +0300 Subject: [PATCH] github: workflows: Organize and make build&test better --- .github/workflows/build-test.yml | 73 ++++++++++++++++++++++++++++++++ .github/workflows/python-app.yml | 40 ----------------- 2 files changed, 73 insertions(+), 40 deletions(-) create mode 100644 .github/workflows/build-test.yml delete mode 100644 .github/workflows/python-app.yml diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml new file mode 100644 index 0000000..6b5ebd5 --- /dev/null +++ b/.github/workflows/build-test.yml @@ -0,0 +1,73 @@ +name: Build & Test + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +permissions: + contents: read + +jobs: + prepare-env: + name: Prepare Python Virtualenv + runs-on: ubuntu-latest + container: shaymargolis/python-mips-gcc + steps: + - uses: actions/checkout@v4 + - name: Set up and install dependencies + run: | + apt update && apt install -yy python3.10-venv + python -m venv .venv + . .venv/bin/activate + pip install --upgrade pip + pip install flake8 pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Archive virtualenv + run: tar czf venv.tar.gz .venv + - name: Upload virtualenv artifact + uses: actions/upload-artifact@v4 + with: + name: python-venv + path: venv.tar.gz + + lint: + name: Lint with flake8 + runs-on: ubuntu-latest + container: shaymargolis/python-mips-gcc + needs: prepare-env + steps: + - uses: actions/checkout@v4 + - name: Download virtualenv artifact + uses: actions/download-artifact@v4 + with: + name: python-venv + - name: Extract virtualenv + run: tar xzf venv.tar.gz + - name: Lint code + run: | + . .venv/bin/activate + flake8 . --exclude .venv --count --select=E9,F63,F7,F82 --show-source --statistics + flake8 . --exclude .venv --count --max-complexity=10 --max-line-length=127 --statistics + + test-matrix: + name: Test on ${{ matrix.arch }} + runs-on: ubuntu-latest + needs: lint + container: shaymargolis/python-mips-gcc + strategy: + matrix: + arch: [mipsbe, mipsle, armle, x86, x86_64] + steps: + - uses: actions/checkout@v4 + - name: Download virtualenv artifact + uses: actions/download-artifact@v4 + with: + name: python-venv + - name: Extract virtualenv + run: tar xzf venv.tar.gz + - name: Run tests + run: | + . .venv/bin/activate + pytest --compiler-arch=${{ matrix.arch }} diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml deleted file mode 100644 index 4c56d75..0000000 --- a/.github/workflows/python-app.yml +++ /dev/null @@ -1,40 +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 - container: shaymargolis/python-mips-gcc - - steps: - - uses: actions/checkout@v4 - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 pytest - 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 --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest - run: | - pytest --compiler-arch=mipsbe - pytest --compiler-arch=mipsle - pytest --compiler-arch=armle - pytest --compiler-arch=x86 - pytest --compiler-arch=x86_64