1
0
mirror of https://github.com/flarum/core.git synced 2025-08-05 16:07:34 +02:00

ci: add Prettier formatting check

This commit is contained in:
David Wheatley
2021-12-29 13:17:12 +01:00
parent 81b27ede28
commit ad41c1f270

View File

@@ -1,17 +1,135 @@
name: Build JavaScript assets
name: JS
on:
push:
branches:
- master
on: [workflow_dispatch, push, pull_request]
env:
NODE_VERSION: 16
jobs:
build:
prettier:
name: Prettier
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: flarum/action-build@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check out code
uses: actions/checkout@v2
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
cache: "yarn"
cache-dependency-path: js/yarn.lock
- name: Install JS dependencies
run: yarn install --immutable
working-directory: ./js
- name: Check JS formatting
run: yarn run format-check
working-directory: ./js
# typecheck:
# name: Typecheck
# runs-on: ubuntu-latest
# steps:
# - name: Check out code
# uses: actions/checkout@v2
# - name: Set up Node
# uses: actions/setup-node@v2
# with:
# node-version: ${{ env.NODE_VERSION }}
# cache: "yarn"
# cache-dependency-path: js/yarn.lock
# - name: Install JS dependencies
# run: yarn --frozen-lockfile
# working-directory: ./js
# - name: Typecheck
# run: yarn run check-typings
# working-directory: ./js
# type-coverage:
# name: Type Coverage
# runs-on: ubuntu-latest
# steps:
# - name: Check out code
# uses: actions/checkout@v2
# - name: Set up Node
# uses: actions/setup-node@v2
# with:
# node-version: ${{ env.NODE_VERSION }}
# cache: "yarn"
# cache-dependency-path: js/yarn.lock
# - name: Install JS dependencies
# run: yarn --frozen-lockfile
# working-directory: ./js
# - name: Check type coverage
# run: yarn run check-typings-coverage
# working-directory: ./js
build-prod:
name: Build and commit
runs-on: ubuntu-latest
needs: [prettier]
# Only commit JS on push to master branch
# Remember to change in `build-test` job too
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
cache: "yarn"
cache-dependency-path: js/yarn.lock
# Our action will install npm, cd into `./js`, run `npm run build`,
# then commit and upload any changes
- name: Build production JS
uses: flarum/action-build@2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
build_script: build
package_manager: yarn
build-test:
name: Test build
runs-on: ubuntu-latest
needs: [prettier]
# Inverse check of `build-prod`
# Remember to change in `build-prod` job too
if: github.ref != 'refs/heads/master' || github.event_name != 'push'
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
cache: "yarn"
cache-dependency-path: js/yarn.lock
# Our action will install npm, cd into `./js`, run `npm run build`,
# then commit and upload any changes
- name: Build production JS
uses: flarum/action-build@2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
build_script: build
package_manager: yarn
do_not_commit: true