github: workflows: Organize and make build&test better #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: | | |
| 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 | |
| needs: prepare-env | |
| container: shaymargolis/python-mips-gcc | |
| 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 . --count --select=E9,F63,F7,F82 --show-source --statistics | |
| flake8 . --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 }} |