update linting workflow

This commit is contained in:
WieErWill 2023-12-10 16:12:46 +01:00
parent 7aba5cf373
commit 274c69d0c4

View File

@ -1,67 +1,108 @@
name: Lint Code Base name: Lint Code Base and Measure Performance
on: [push, pull_request] on: [push, pull_request]
jobs: jobs:
build: lint-python:
name: Lint name: Lint Python
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy:
fail-fast: false
steps: steps:
# Checkout the repository - name: Checkout Repository
- name: Checkout Repository uses: actions/checkout@v2
uses: actions/checkout@v2
# Setup Python - name: Set up Python
- name: Set up Python uses: actions/setup-python@v2
uses: actions/setup-python@v2 with:
with: python-version: '3.x'
python-version: '3.x'
# Lint Python files - name: Lint Python Files
- name: Lint Python run: |
run: | pip install flake8
pip install flake8 flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# Stop the build if there are Python syntax errors or undefined names flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
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
# Setup Node.js for JavaScript and TypeScript lint-javascript:
- name: Set up Node.js name: Lint JavaScript
uses: actions/setup-node@v2 runs-on: ubuntu-latest
with: needs: lint-python
node-version: '16'
# Lint JavaScript files steps:
- name: Lint JavaScript - name: Checkout Repository
run: | uses: actions/checkout@v2
npm install
npm run lint
# Lint TypeScript files - name: Set up Node.js
- name: Lint TypeScript uses: actions/setup-node@v2
run: | with:
npm install node-version: '16'
npm run lint
# Setup Rust - name: Lint JavaScript Files
- name: Set up Rust run: |
uses: actions-rs/toolchain@v1 npm install
with: npm run lint
toolchain: stable
override: true
# Lint Rust files lint-typescript:
- name: Lint Rust name: Lint TypeScript
run: | runs-on: ubuntu-latest
for dir in Day*/rust; do needs: lint-javascript
if [ -d "$dir" ]; then
echo "Linting $dir" steps:
cd $dir - name: Checkout Repository
cargo clippy -- -D warnings uses: actions/checkout@v2
cd - # Go back to the root directory
fi - name: Set up Node.js
done uses: actions/setup-node@v2
with:
node-version: '16'
- name: Lint TypeScript Files
run: |
npm install
npm run lint
lint-rust:
name: Lint Rust
runs-on: ubuntu-latest
needs: lint-typescript
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Lint Rust Files
run: |
for dir in Day*/rust; do
if [ -d "$dir" ]; then
echo "Linting $dir"
cd $dir
cargo clippy -- -D warnings
cd - # Go back to the root directory
fi
done
measure_performance:
name: Measure Performance
runs-on: ubuntu-latest
needs: [lint-python, lint-javascript, lint-typescript, lint-rust]
timeout-minutes: 15 # Timeout set to 15 minutes
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Run Performance Measurement Script
run: |
chmod +x ./measure_performance.sh
./measure_performance.sh
- name: Upload Analytics.md
uses: actions/upload-artifact@v2
with:
name: Analytics
path: Analytics.md