Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workflow to format and lint code #235

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
stash-realbooru.js
visage.js
28 changes: 28 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": ["eslint:recommended"],
"overrides": [],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"globals": {
"stash": "readonly",
"PluginApi": "readonly"
},
"rules": {
"quotes": ["warn", "double"],
"no-console": ["warn", { "allow": ["error", "warn", "debug"] }],
"no-unused-vars": "warn",
"no-undef": "warn",
"camelcase": ["warn"],
"no-case-declarations": "off",
"no-prototype-builtins": "off",
"no-inner-declarations": "off",
"no-extra-semi": "off",
"no-empty": "off"
}
}
83 changes: 41 additions & 42 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,50 @@
name: Deploy repository to Github Pages

on:
push:
branches: [ main, stable ]
push:
branches: [main, stable]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
contents: read
pages: write
id-token: write

jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Checkout main
uses: actions/checkout@v2
with:
path: main
ref: main
fetch-depth: '0'
- run: |
cd main
./build_site.sh ../_site/stable
- name: Checkout dev
uses: actions/checkout@v2
with:
path: dev
# change this ref to whatever dev branch/tag we need when necessary
ref: main
fetch-depth: '0'
- run: |
cd dev
../main/build_site.sh ../_site/develop
- uses: actions/upload-pages-artifact@v2

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-22.04
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2

build:
runs-on: ubuntu-22.04
steps:
- name: Checkout main
uses: actions/checkout@v2
with:
path: main
ref: main
fetch-depth: "0"
- run: |
cd main
./build_site.sh ../_site/stable
- name: Checkout dev
uses: actions/checkout@v2
with:
path: dev
# change this ref to whatever dev branch/tag we need when necessary
ref: main
fetch-depth: "0"
- run: |
cd dev
../main/build_site.sh ../_site/develop
- uses: actions/upload-pages-artifact@v2

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-22.04
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
70 changes: 70 additions & 0 deletions .github/workflows/process_code.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Pull Request

on:
push:
branches:
- main
pull_request:
branches:
- main

permissions:
contents: write

jobs:
format_js:
name: Format JS code
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.head_ref }}

- name: Prettify code
uses: creyD/[email protected]
with:
prettier_options: --write .
only_changed: true
commit_message: "gh-actions: format code"
github_token: ${{ secrets.GITHUB_TOKEN }}

lint_js:
name: Lint JS code
runs-on: ubuntu-latest
needs: format_js

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.head_ref }}

- name: Install node.js
uses: actions/setup-node@v4
with:
node-version: 20.x

- name: Install repository dependencies
run: npm ci

- name: Run eslint
run: npm run lint-errors

format_py:
name: Format py code
runs-on: ubuntu-latest
needs: lint_js

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.head_ref }}

- name: Format py code
uses: psf/black@stable
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/_site
/_site
node_modules
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# dependencies
node_modules
8 changes: 8 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"trailingComma": "es5",
"tabWidth": 4,
"useTabs": false,
"semi": false,
"singleQuote": false,
"printWidth": 150
}
Loading
Loading