Skip to content

Commit

Permalink
feat: Actions (#3)
Browse files Browse the repository at this point in the history
Implementate alcune Github Action per automatizzare alcune fasi dello
sviluppo del codice

## Linter

Aggiunta action che è in grado di eseguire il linter (sia python che JS)
e scansionare alcuni problemi del codice.
Questa action si attiva solo quando viene aperta una PR per branch
`develop` o `main`.
Gli errori vengono riportarti come commenti quando si analizzano le
modifiche dei file.

## DevBuild

Aggiunta action in grado di eseguire la build per AARCH64,
l'architettura del rasberry e produrre un eseguibile per questo.
Questa action si attiva quando viene eseguito il push di qualche commit
nel branch `testing-build`.
L'action genera in automatico una PRE-RELEASE con l'eseguibile. Ogni
volta che viene eseguita la pre-release viene aggiornata e si perde
quella precedente.

## Production Build

Aggiunta action in grado di generare la build per ARMV7 pronta per la
produzione.
L'action si attiva quando una PR verso il branch `main` viene mergiata
con successo.
Produce una RELEASE con il nome della PR (*il nome della PR non deve
contenere spazi e dovrebbe essere del tipo V1.0*) e con l'eseguibile

## Dependabot

Aggiunto supporto per il dependabot.
Controlla:

- pip
- npm
- github actions
  • Loading branch information
ncvescera authored Jun 7, 2023
2 parents 371d32f + e14e8b4 commit 7a66f5f
Show file tree
Hide file tree
Showing 5 changed files with 204 additions and 12 deletions.
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"

- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"

- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "daily"
64 changes: 64 additions & 0 deletions .github/workflows/aarch64-devbuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: "Build on ARM"

on:
push:
branches:
- 'testing-build'

permissions:
id-token: write
contents: write
packages: write
pull-requests: read

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Build on ARM
uses: pguyot/arm-runner-action@v2
id: build_image
with:
copy_artifact_path: dist/react-pywebview-boilerplate
copy_artifact_dest: .
base_image: raspios_lite:latest
cpu: cortex-a7
cpu_info: cpuinfo/raspberrypi_3b
image_additional_mb: 4096
commands: |
sudo apt update
sudo apt install python3-pip -y
pip3 install virtualenv
curl -sL https://deb.nodesource.com/setup_18.x | sudo bash -
sudo apt install nodejs -y
npm install --global yarn
yarn run init
export CI=false
yarn run build
- name: Upload executable
uses: actions/upload-artifact@v3
with:
name: devbuild
path: react-pywebview-boilerplate

prerelease:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Download Executable
uses: actions/download-artifact@v3
with:
name: devbuild
- name: Create DevBuild
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest"
prerelease: true
title: "Development Build"
files: |
react-pywebview-boilerplate
65 changes: 65 additions & 0 deletions .github/workflows/auto-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Create Release

on:
pull_request:
branches:
- main
types:
- closed

permissions:
id-token: write
contents: write
packages: write
pull-requests: read

jobs:
build:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Build on ARM
uses: pguyot/arm-runner-action@v2
id: build_image
with:
copy_artifact_path: dist/react-pywebview-boilerplate
copy_artifact_dest: .
base_image: raspios_lite:latest
cpu: cortex-a7
cpu_info: cpuinfo/raspberrypi_3b
image_additional_mb: 4096
commands: |
sudo apt update
sudo apt install python3-pip -y
pip3 install virtualenv
curl -sL https://deb.nodesource.com/setup_18.x | sudo bash -
sudo apt install nodejs -y
npm install --global yarn
yarn run init
yarn run build
- name: Upload executable
uses: actions/upload-artifact@v3
with:
name: releasebuild
path: react-pywebview-boilerplate

release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Download Executable
uses: actions/download-artifact@v3
with:
name: releasebuild
- name: Create Release
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "${{ github.event.pull_request.title }}"
prerelease: false
files: |
react-pywebview-boilerplate
42 changes: 42 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Lint

on:
# Replace pull_request with pull_request_target if you
# plan to use this action with forks, see the Limitations section
pull_request:
branches:
- main
- develop

# Down scope as necessary via https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
permissions:
checks: write
contents: write

jobs:
run-linters:
name: Run linters
runs-on: ubuntu-latest

steps:
- name: Check out Git repository
uses: actions/checkout@v3

- name: Set up Python 3
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
# fix temporaneo. @Fabrizio ricontrollare configurazione di eslint
- name: Install Node.js dependencies
run: yarn install

- name: Run linters
uses: wearerequired/lint-action@v2
with:
xo: true
flake8: true
29 changes: 17 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,19 @@
"cleanall:windows": "if exist node_modules rd /S /Q node_modules & if exist venv-pywebview rd /S /Q venv-pywebview",
"init": "yarn install && run-script-os",
"init:windows": "virtualenv -p python venv-pywebview && .\\venv-pywebview\\Scripts\\pip install -r requirements.txt",
"init:linux": "virtualenv -p python3 venv-pywebview && if [[ -z \"${KDE_FULL_SESSION}\" ]]; then yarn run init:qt5; else yarn run init:gtk; fi",
"init:default": "virtualenv -p python3 venv-pywebview && ./venv-pywebview/bin/pip install -r requirements.txt",
"init:qt5": "./venv-pywebview/bin/pip install pyqt5 pyqtwebengine -r requirements.txt",
"init:gtk": "./venv-pywebview/bin/pip install pycairo PyGObject -r requirements.txt",
"//init:gtk": "sudo apt install libgirepository1.0-dev gcc libcairo2-dev pkg-config python3-dev gir1.2-gtk-3.0 && ./venv-pywebview/bin/pip install pycairo pygobject -r requirements.txt",
"init:linux": "virtualenv -p python3 venv-pywebview && yarn run init:gtk",
"init:default": "virtualenv -p python4 venv-pywebview && ./venv-pywebview/bin/pip install -r requirements.txt",
"init:gtk": "sudo apt install -y libgirepository1.0-dev gcc libcairo2-dev pkg-config python3-dev gir1.2-gtk-3.0 && ./venv-pywebview/bin/pip install pycairo pygobject -r requirements.txt",
"init:docs": "./venv-pywebview/bin/pip install pylama yapf",
"start": "export NODE_OPTIONS='--openssl-legacy-provider' && yarn run frontend:dev && run-script-os",
"start:windows": ".\\venv-pywebview\\Scripts\\python src\\index.py",
"start:default": "./venv-pywebview/bin/python src/index.py",
"pylintcheck": "pylama -f pylint ./src/",
"pylint": "yapf --recursive -i ./src/"
"pylint": "yapf --recursive -i ./src/",
"lint": "xo src/"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
"xo": {
"extends": "xo-react"
},
"browserslist": {
"production": [
Expand All @@ -71,6 +67,15 @@
]
},
"devDependencies": {
"run-script-os": "^1.1.6"
"eslint": "^8.41.0",
"eslint-config-standard": "^17.1.0",
"eslint-config-xo-react": "^0.27.0",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-n": "^15.0.0 || ^16.0.0 ",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"run-script-os": "^1.1.6",
"xo": "^0.54.2"
}
}

0 comments on commit 7a66f5f

Please sign in to comment.