Skip to content

Commit 9f0e428

Browse files
committed
Update workflows based on graphql-voyager's
1 parent 7d01eb6 commit 9f0e428

File tree

6 files changed

+154
-16
lines changed

6 files changed

+154
-16
lines changed

.github/workflows/ci.yml

Lines changed: 119 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,138 @@
11
name: CI
2-
on: [push, pull_request]
2+
on: workflow_call
3+
permissions: {}
34
jobs:
45
lint:
56
name: Lint source files
67
runs-on: ubuntu-latest
8+
permissions:
9+
contents: read # for actions/checkout
710
steps:
811
- name: Checkout repo
9-
uses: actions/checkout@v2
12+
uses: actions/checkout@v3
13+
with:
14+
persist-credentials: false
1015

1116
- name: Setup Node.js
12-
uses: actions/setup-node@v1
13-
14-
- name: Cache Node.js modules
15-
uses: actions/cache@v2
17+
uses: actions/setup-node@v3
1618
with:
17-
path: ~/.npm
18-
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
19-
restore-keys: |
20-
${{ runner.OS }}-node-
19+
cache: npm
20+
node-version-file: '.node-version'
2121

2222
- name: Install Dependencies
23-
run: npm ci
23+
run: npm ci --ignore-scripts
24+
25+
- name: Lint ESLint
26+
run: npm run lint
2427

2528
- name: Check Types
2629
run: npm run check
2730

2831
- name: Lint Prettier
2932
run: npm run prettier:check
3033

31-
- name: Build package
32-
run: npm run build:all
33-
shell: bash
34+
- name: Spellcheck
35+
run: npm run check:spelling
36+
37+
- name: Lint GitHub Actions
38+
uses: docker://rhysd/actionlint:latest
39+
with:
40+
args: -color
41+
42+
checkForCommonlyIgnoredFiles:
43+
name: Check for commonly ignored files
44+
runs-on: ubuntu-latest
45+
permissions:
46+
contents: read # for actions/checkout
47+
steps:
48+
- name: Checkout repo
49+
uses: actions/checkout@v3
50+
with:
51+
persist-credentials: false
52+
53+
- name: Check if commit contains files that should be ignored
54+
run: |
55+
git clone --depth 1 https://github.com/github/gitignore.git
56+
57+
rm gitignore/Global/ModelSim.gitignore
58+
rm gitignore/Global/Images.gitignore
59+
rm gitignore/Global/VirtualEnv.gitignore
60+
cat gitignore/Node.gitignore gitignore/Global/*.gitignore > all.gitignore
61+
62+
IGNORED_FILES=$(git ls-files --cached --ignored --exclude-from=all.gitignore)
63+
if [[ "$IGNORED_FILES" != "" ]]; then
64+
echo -e "::error::Please remove these files:\n$IGNORED_FILES" | sed -z 's/\n/%0A/g'
65+
exit 1
66+
fi
67+
68+
checkPackageLock:
69+
name: Check health of package-lock.json file
70+
runs-on: ubuntu-latest
71+
permissions:
72+
contents: read # for actions/checkout
73+
steps:
74+
- name: Checkout repo
75+
uses: actions/checkout@v3
76+
with:
77+
persist-credentials: false
78+
79+
- name: Setup Node.js
80+
uses: actions/setup-node@v3
81+
with:
82+
cache: npm
83+
node-version-file: '.node-version'
84+
85+
- name: Install Dependencies
86+
run: npm ci --ignore-scripts
87+
88+
- name: Check that package-lock.json doesn't have conflicts
89+
run: npm ls --depth 999
90+
91+
- name: Run npm install
92+
run: npm install --ignore-scripts --force --package-lock-only --engine-strict --strict-peer-deps
93+
94+
- name: Check that package-lock.json is in sync with package.json
95+
run: git diff --exit-code package-lock.json
96+
97+
codeql:
98+
name: Run CodeQL security scan
99+
runs-on: ubuntu-latest
100+
permissions:
101+
contents: read # for actions/checkout
102+
security-events: write # for codeql-action
103+
steps:
104+
- name: Checkout repo
105+
uses: actions/checkout@v3
106+
with:
107+
persist-credentials: false
108+
109+
- name: Initialize CodeQL
110+
uses: github/codeql-action/init@v2
111+
with:
112+
languages: 'javascript, typescript'
113+
114+
- name: Perform CodeQL analysis
115+
uses: github/codeql-action/analyze@v2
116+
117+
buildRelease:
118+
name: Build release
119+
runs-on: ubuntu-latest
120+
permissions:
121+
contents: read # for actions/checkout
122+
steps:
123+
- name: Checkout repo
124+
uses: actions/checkout@v3
125+
with:
126+
persist-credentials: false
127+
128+
- name: Setup Node.js
129+
uses: actions/setup-node@v3
130+
with:
131+
cache: npm
132+
node-version-file: '.node-version'
133+
134+
- name: Install Dependencies
135+
run: npm ci --ignore-scripts
136+
137+
- name: Build release
138+
run: npm run build

.github/workflows/pull_request.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: PullRequest
2+
on: pull_request
3+
permissions: {}
4+
jobs:
5+
ci:
6+
permissions:
7+
contents: read # for actions/checkout
8+
security-events: write # for codeql-action
9+
uses: ./.github/workflows/ci.yml
10+
11+
dependency-review:
12+
name: Security check of added dependencies
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read # for actions/checkout
16+
steps:
17+
- name: Checkout repo
18+
uses: actions/checkout@v3
19+
with:
20+
persist-credentials: false
21+
22+
- name: Dependency review
23+
uses: actions/dependency-review-action@v2

.github/workflows/push.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: Push
2+
on: push
3+
permissions: {}
4+
jobs:
5+
ci:
6+
permissions:
7+
contents: read # for actions/checkout
8+
security-events: write # for codeql-action
9+
uses: ./.github/workflows/ci.yml

.node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v19

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,6 @@ Because the process is running inside of the container, `--open` does not work.
101101

102102
```sh
103103
npm i
104-
npm run build:all
104+
npm run build
105105
npm run start
106106
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"build:typescript": "tsc",
3232
"copy:graphql": "cp src/*.graphql dist/",
3333
"copy:editor": "mkdir \"dist/editor\" && cp src/editor/*.html dist/editor && cp src/editor/*.js dist/editor && cp src/editor/*.css dist/editor && cp src/editor/*.svg dist/editor",
34-
"build:all": "rm -rf dist && mkdir dist && npm run build:editor && npm run build:typescript && npm run copy:graphql && npm run copy:editor",
34+
"build": "rm -rf dist && mkdir dist && npm run build:editor && npm run build:typescript && npm run copy:graphql && npm run copy:editor",
3535
"prettier": "prettier --cache --ignore-path .gitignore --write --list-different .",
3636
"prettier:check": "prettier --cache --ignore-path .gitignore --check .",
3737
"check:spelling": "cspell --cache --no-progress '**/*'"

0 commit comments

Comments
 (0)