Skip to content

Commit 646e7c8

Browse files
authored
Merge pull request #1 from frontend-fun/update-branches
Big 2024 update to starter files and workflow
2 parents 9d0f9b3 + 55f976e commit 646e7c8

16 files changed

+18953
-20776
lines changed

.eslintoutputrc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"files": [
3+
"."
4+
],
5+
"formats": [
6+
{
7+
"name": "stylish",
8+
"output": "console"
9+
},
10+
{
11+
"name": "html",
12+
"output": "file",
13+
"path": "dist/lint.html",
14+
"id": "html"
15+
}
16+
],
17+
"eslintConfig": {}
18+
}

.eslintrc.js

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
module.exports = {
2+
env: {
3+
es2022: true,
4+
node: true,
5+
browser: true,
6+
},
7+
settings: {
8+
react: {
9+
version: "detect",
10+
},
11+
},
12+
extends: [
13+
"eslint:recommended",
14+
"plugin:react/recommended",
15+
"plugin:react-hooks/recommended",
16+
],
17+
root: true,
18+
parser: "@typescript-eslint/parser",
19+
plugins: ["@typescript-eslint", "react"],
20+
overrides: [
21+
{
22+
files: ["src/**/*.test.ts", "src/**/*.test.tsx"],
23+
env: {
24+
jest: true,
25+
},
26+
},
27+
],
28+
parserOptions: {
29+
ecmaVersion: 12,
30+
sourceType: "module",
31+
ecmaFeatures: {
32+
jsx: true,
33+
},
34+
project: ["./tsconfig.json"],
35+
},
36+
ignorePatterns: [".eslintrc.js"],
37+
rules: {
38+
// https://stackoverflow.com/questions/57802057/eslint-configuring-no-unused-vars-for-typescript
39+
// Use typescript's checker for unused vars (critical for Enums)
40+
"no-unused-vars": "off",
41+
"@typescript-eslint/no-unused-vars": ["error"],
42+
// https://typescript-eslint.io/rules/no-use-before-define
43+
"no-use-before-define": "off",
44+
"@typescript-eslint/no-use-before-define": "error",
45+
46+
// https://typescript-eslint.io/rules/ban-ts-comment
47+
// Disallow @ts-<directive> comments or require descriptions after directives.
48+
"@typescript-eslint/ban-ts-comment": "error",
49+
50+
// https://typescript-eslint.io/rules/no-explicit-any
51+
// Disallow the any type.
52+
//"@typescript-eslint/no-explicit-any": "error",
53+
54+
// https://typescript-eslint.io/rules/no-unsafe-assignment
55+
// Disallow assigning a value with type any to variables and properties.
56+
"@typescript-eslint/no-unsafe-assignment": "error",
57+
58+
// https://typescript-eslint.io/rules/no-unsafe-return
59+
// Disallow returning a value with type any from a function.
60+
"@typescript-eslint/no-unsafe-return": "error",
61+
62+
// https://typescript-eslint.io/rules/ban-types
63+
// Disallow certain types.
64+
"@typescript-eslint/no-restricted-types": [
65+
"error",
66+
{
67+
types: {
68+
unknown:
69+
"That is not allowed in this course. You should be able to specify the type more clearly!",
70+
any: "That is not allowed in this course. You should be able to figure out the type!",
71+
},
72+
},
73+
],
74+
// https://typescript-eslint.io/rules/no-array-constructor
75+
// Disallow generic Array constructors.
76+
"no-array-constructor": "off",
77+
"@typescript-eslint/no-array-constructor": "error",
78+
79+
// https://typescript-eslint.io/rules/no-base-to-string
80+
// Require .toString() to only be called on objects which provide useful information when stringified.
81+
"@typescript-eslint/no-base-to-string": "error",
82+
83+
// https://typescript-eslint.io/rules/no-confusing-void-expression
84+
// Require expressions of type void to appear in statement position.
85+
"@typescript-eslint/no-confusing-void-expression": "error",
86+
87+
// https://typescript-eslint.io/rules/no-for-in-array
88+
// Disallow iterating over an array with a for-in loop. (Force for-of instead!)
89+
"@typescript-eslint/no-for-in-array": "error",
90+
91+
// https://typescript-eslint.io/rules/no-unnecessary-boolean-literal-compare
92+
// Disallow unnecessary equality comparisons against boolean literals.
93+
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "error",
94+
95+
// https://typescript-eslint.io/rules/no-unnecessary-condition
96+
// Disallow conditionals where the type is always truthy or always falsy.
97+
"@typescript-eslint/no-unnecessary-condition": "error",
98+
},
99+
};

.eslintrc.json

Lines changed: 0 additions & 49 deletions
This file was deleted.

.github/workflows/node.js.yml

Lines changed: 163 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,40 @@
1-
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
1+
# Workflow for publishing the students' website along with additional helpful information
32

4-
name: Node.js CI
3+
name: Deploy main branch as website
54

65
on:
76
push:
87
branches: [main]
98

10-
jobs:
11-
build:
12-
runs-on: ubuntu-latest
9+
# Allows you to run this workflow manually from the Actions tab
10+
workflow_dispatch:
11+
12+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
13+
permissions:
14+
contents: read
15+
pages: write
16+
id-token: write
1317

14-
strategy:
15-
matrix:
16-
node-version: [16.x]
17-
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
18+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
19+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
20+
concurrency:
21+
group: "pages"
22+
cancel-in-progress: false
1823

24+
jobs:
25+
checkout:
26+
runs-on: ubuntu-latest
1927
steps:
20-
- uses: actions/checkout@v2
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
2132
- name: Use Node.js ${{ matrix.node-version }}
22-
uses: actions/setup-node@v2
33+
uses: actions/setup-node@v3
2334
with:
2435
node-version: ${{ matrix.node-version }}
25-
cache: "npm"
2636
- id: get-repo-values
37+
name: Get repository values
2738
run: |
2839
url=https://$(echo "${{github.repository}}" | sed "s/\//.github.io\//")
2940
echo "url=$url" >> $GITHUB_OUTPUT
@@ -33,20 +44,142 @@ jobs:
3344
file: package.json
3445
field: homepage
3546
value: ${{ steps.get-repo-values.outputs.url }}
36-
- run: npm ci
37-
- run: npm run lint
38-
- run: npm run test -- --coverage |& tee ./public/test_report.txt
39-
- run: echo "<html><head><meta http-equiv='refresh' content='0; URL=${{github.server_url}}/${{github.repository}}' /></head><body>Redirecting to repository</body></html>" > ./public/github.html
40-
- run: npm run build --if-present
41-
42-
- name: Deploy
43-
run: |
44-
git config --global user.name ${user_name}
45-
git config --global user.email ${user_email}
46-
git remote set-url origin https://${github_token}@github.com/${repository}
47-
npm run deploy
48-
env:
49-
user_name: "github-actions[bot]"
50-
user_email: "github-actions[bot]@users.noreply.github.com"
51-
github_token: ${{ secrets.GH_TOKEN }}
52-
repository: ${{ github.repository }}
47+
48+
create_redirects:
49+
runs-on: ubuntu-latest
50+
needs: checkout
51+
steps:
52+
- name: Create Redirects and Links
53+
run: |
54+
echo "<html><head>\
55+
<meta http-equiv='refresh' content='0; URL=${{github.server_url}}/${{github.repository}}' />\
56+
</head><body>Redirecting to repository</body></html>" > ./dist/repo.html
57+
58+
mkdir -p docs
59+
cp README.md docs/index.md
60+
echo "# Quick Links" > docs/quick-links.md
61+
echo "* [Repository](../repo.html)" >> docs/quick-links.md
62+
echo "<html><head>\
63+
<meta http-equiv='refresh' content='0; URL=docs/quick-links' />\
64+
</head><body>Redirecting to quick links page</body></html>" > ./dist/quick.html
65+
66+
install:
67+
runs-on: ubuntu-latest
68+
needs: create_redirects
69+
steps:
70+
# Install node packages
71+
- name: Install
72+
run: |
73+
echo "<html><body><pre>" > ./dist/installation.html
74+
npm install |& tee -a ./dist/installation.html
75+
echo "</pre></body></html>" >> ./dist/installation.html
76+
echo "* [Installation](../installation.html)" >> docs/quick-links.md
77+
78+
lint:
79+
runs-on: ubuntu-latest
80+
needs: install
81+
if: success()
82+
steps:
83+
- name: Run Linter
84+
run: |
85+
npm run eslint-output
86+
echo "* [Linter](../lint.html)" >> docs/quick-links.md
87+
88+
build:
89+
runs-on: ubuntu-latest
90+
needs: lint
91+
if: success()
92+
steps:
93+
- name: Build the project
94+
run: |
95+
echo "<html><body><pre>" > ./dist/build.html
96+
npm run build |& tee -a ./dist/build.html
97+
echo "</pre></body></html>" >> ./dist/build.html
98+
echo "* [Build](../build.html)" >> docs/quick-links.md
99+
100+
test:
101+
runs-on: ubuntu-latest
102+
needs: build
103+
if: success()
104+
steps:
105+
- name: Run Tests
106+
run: |
107+
echo "<html><body><pre>" > ./dist/tests.html
108+
npm run test -- --coverage |& tee -a ./dist/tests.html
109+
echo "</pre></body></html>" >> ./dist/tests.html
110+
echo "* [Tests](../tests.html)" >> docs/quick-links.md
111+
112+
integrity:
113+
runs-on: ubuntu-latest
114+
needs: create_redirects
115+
if: success()
116+
steps:
117+
- name: Verify Integrity
118+
run: |
119+
echo "<html><body><pre>" > ./dist/integrity.html
120+
FILES="test/* .eslintrc.js .eslintrc.json .github/workflows/deploy.yml src/**/*.test.ts src/**/*.test.tsx"
121+
for pattern in $FILES; do
122+
for file in $(find . -path "$pattern"); do
123+
md5sum "$file" >> ./dist/integrity.html
124+
done
125+
done
126+
echo "</pre></body></html>" >> ./dist/integrity.html
127+
echo "* [Integrity](../integrity.html)" >> docs/quick-links.md
128+
129+
git_inspector:
130+
runs-on: ubuntu-latest
131+
needs: create_redirects
132+
steps:
133+
- name: Create GitInspector Report
134+
run: |
135+
git clone https://github.com/jpwhite3/gitinspector.git
136+
python ./gitinspector/gitinspector.py ./ --grading --format=html -f tsx,ts,html,css -x ./gitinspector -x ./node_modules -x ./wbcore > ./dist/git.html
137+
echo "* [Git Inspector](../git.html)" >> docs/quick-links.md
138+
139+
generate_docs:
140+
runs-on: ubuntu-latest
141+
needs: [install, lint, build, test, integrity, git_inspector]
142+
if: success() || failure()
143+
steps:
144+
- name: Generate HTML from Markdown in Docs/
145+
uses: ldeluigi/markdown-docs@latest
146+
with:
147+
src: docs
148+
dst: dist/docs/
149+
150+
deploy:
151+
runs-on: ubuntu-latest
152+
needs: generate_docs
153+
steps:
154+
- name: Setup Pages
155+
uses: actions/configure-pages@v3
156+
- name: Upload artifact
157+
uses: actions/upload-pages-artifact@v2
158+
with:
159+
path: "dist/"
160+
- name: Deploy to GitHub Pages
161+
id: deployment
162+
uses: actions/deploy-pages@v2
163+
164+
handle_failure:
165+
runs-on: ubuntu-latest
166+
needs: [create_redirects, checkout, generate_docs, deploy]
167+
if: failure()
168+
steps:
169+
- name: Handle Failure
170+
run: |
171+
echo "<html><body><h1>Build Failure</h1><p>The build failed during one of the steps.</p>" > ./dist/index.html
172+
- uses: austenstone/[email protected]
173+
id: job-summary
174+
with:
175+
create-pdf: false
176+
- run: |
177+
echo "${{ steps.job-summary.outputs.job-summary }}" >> ./dist/index.html
178+
echo "</body></html>" >> ./dist/index.html
179+
- name: Upload failure artifact
180+
uses: actions/upload-pages-artifact@v2
181+
with:
182+
path: "dist/"
183+
- name: Deploy to GitHub Pages
184+
id: deployment
185+
uses: actions/deploy-pages@v2

0 commit comments

Comments
 (0)