name: EU-Utility CI/CD on: push: branches: [ main, develop ] pull_request: branches: [ main ] release: types: [ created ] jobs: test: runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest, windows-latest] python-version: ['3.11', '3.12'] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Cache pip packages uses: actions/cache@v3 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} restore-keys: | ${{ runner.os }}-pip- - name: Install dependencies run: | python -m pip install --upgrade pip pip install flake8 pytest pytest-cov pip install -r requirements.txt - name: Lint with flake8 run: | # Stop 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 flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Test with pytest run: | pytest tests/ -v --cov=core --cov=plugins --cov-report=xml --cov-report=term - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 with: file: ./coverage.xml flags: unittests name: codecov-umbrella build: needs: test runs-on: ${{ matrix.os }} strategy: matrix: os: [windows-latest, ubuntu-latest] steps: - uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v4 with: python-version: '3.11' - name: Install dependencies run: | python -m pip install --upgrade pip pip install pyinstaller pip install -r requirements.txt - name: Build executable (Windows) if: matrix.os == 'windows-latest' run: | pyinstaller --noconfirm --onefile --windowed --name EU-Utility --icon=assets/icon.ico core/main.py - name: Build executable (Linux) if: matrix.os == 'ubuntu-latest' run: | pyinstaller --noconfirm --onefile --name EU-Utility core/main.py - name: Upload artifact uses: actions/upload-artifact@v3 with: name: EU-Utility-${{ matrix.os }} path: dist/ release: needs: [test, build] runs-on: ubuntu-latest if: github.event_name == 'release' steps: - uses: actions/checkout@v3 - name: Download all artifacts uses: actions/download-artifact@v3 - name: Display structure run: ls -R - name: Zip artifacts run: | zip -r EU-Utility-Windows.zip EU-Utility-windows-latest/ zip -r EU-Utility-Linux.zip EU-Utility-ubuntu-latest/ - name: Upload to Release uses: softprops/action-gh-release@v1 with: files: | EU-Utility-Windows.zip EU-Utility-Linux.zip env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} docs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v4 with: python-version: '3.11' - name: Install docs dependencies run: | pip install mkdocs mkdocs-material - name: Build documentation run: | mkdocs build - name: Deploy to GitHub Pages if: github.ref == 'refs/heads/main' uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./site