Skip to content

Commit

Permalink
Merge pull request #25 from n30w/18-add-github-actions
Browse files Browse the repository at this point in the history
feat: add GitHub actions files
  • Loading branch information
reesedychiao authored Mar 14, 2024
2 parents efd8718 + 9161484 commit a58a5f0
Show file tree
Hide file tree
Showing 11 changed files with 141 additions and 21 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Backend

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

jobs:
build:
runs-on: ubuntu-latest

defaults:
run:
working-directory: ./backend

steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.22"

- name: Test
run: go test -v ./...

- name: Build
run: go build -v ./...
33 changes: 33 additions & 0 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Frontend

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

defaults:
run:
working-directory: ./frontend

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "latest"
- name: enable corepack
run: corepack enable
- name: set yarn version
run: corepack use yarn@stable
- name: install dependencies
run: yarn
- name: run eslint
run: yarn lint
- name: format with prettier
run: yarn format:fix
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"cSpell.words": [
"cmds",
"corepack",
"Darkspace",
"healthcheck",
"idnum",
Expand Down
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,26 @@ One must have installed these utilities to start development:
- Go
- Node

### MacOS

If you're using MacOS, ```corepack``` is also needed. Corepack ships with Node, but zsh does not find this linkage in the shell. Therefore, since we are using brew, corepack can be installed with:

```brew install corepack```

Brew may error and say that you must remove the symlink for ```yarn``` if you used brew to install yarn. Do not fret, run this command:

```brew unlink yarn```

Then, rerun ```brew install corepack```.

Now, run ```corepack enable```. This will enable corepack globally. Optionally, one can run ```corepack install --global yarn@stable``` to install the latest yarn version globally using corepack.

To set the yarn version in the frontend directory, first ```cd frontend``` then ```corepack use yarn@v```, where ```v``` is the version you want to set. In this project, we are using stable, so the command would be ```corepack use yarn@stable```.

#### Aside

Corepack is used in the GitHub workflow file to make ensure yarn can install.

## Software

Below is a list of software one may use to code this project:
Expand Down Expand Up @@ -116,4 +136,4 @@ We must implement endpoint testing.

Here are software development terms that may be unfamiliar and are found during the development process.

- [Triage](https://dictionary.cambridge.org/dictionary/english/triage)
- [Triage](https://dictionary.cambridge.org/dictionary/english/triage)
25 changes: 12 additions & 13 deletions backend/cmd/api/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,22 @@ func (app *application) courseHomepageHandler(
w http.ResponseWriter,
r *http.Request,
) {
// Retrieve that value of the {id} path in the URL using r.PathValue("id")
id := r.PathValue("id")
// id := r.PathValue("id")

var course *models.Course
var err error
// var course *models.Course
// var err error

course, err = app.models.Course.Get(id)
if err != nil {
app.serverError(w, r, err)
}
// course, err = app.models.Course.Get(id)
// if err != nil {
// app.serverError(w, r, err)
// }

res := jsonWrap{}
// res := jsonWrap{"course": course}

err = app.writeJSON(w, http.StatusOK, res, nil)
if err != nil {
app.serverError(w, r, err)
}
// err = app.writeJSON(w, http.StatusOK, res, nil)
// if err != nil {
// app.serverError(w, r, err)
// }

// If the course ID exists in the database AND the user requesting this
// data has the appropriate permissions, retrieve the course data requested.
Expand Down
2 changes: 1 addition & 1 deletion backend/internal/domain/permission_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestPermission_String(t *testing.T) {
p.update = true
p.delete = true

want := "----"
want := "rwud"

got := fmt.Sprintf("%s", p)

Expand Down
7 changes: 6 additions & 1 deletion frontend/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{
"extends": "next/core-web-vitals"
"extends": ["next/core-web-vitals", "prettier"],
"rules": {
"@next/next/no-html-link-for-pages": ["error"],
"@next/next/no-img-element": ["error"],
"@next/next/no-typos": ["error"]
}
}
2 changes: 0 additions & 2 deletions frontend/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
yarnPath: .yarn/releases/yarn-4.1.0.cjs

# Fix for GitHub Issue #3
nodeLinker: node-modules
8 changes: 6 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
"lint": "next lint",
"format": "prettier --check ./src",
"format:fix": "prettier --write --list-different ./src"
},
"dependencies": {
"next": "14.1.0",
Expand All @@ -20,9 +22,11 @@
"autoprefixer": "^10.0.1",
"eslint": "^8",
"eslint-config-next": "14.1.0",
"eslint-config-prettier": "^9.1.0",
"postcss": "^8",
"prettier": "^3.2.5",
"tailwindcss": "^3.3.0",
"typescript": "^5"
},
"packageManager": "[email protected].0"
"packageManager": "[email protected].1+sha256.f3cc0eda8e5560e529c7147565b30faa43b4e472d90e8634d7134a37c7f59781"
}
22 changes: 22 additions & 0 deletions frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1272,6 +1272,17 @@ __metadata:
languageName: node
linkType: hard

"eslint-config-prettier@npm:^9.1.0":
version: 9.1.0
resolution: "eslint-config-prettier@npm:9.1.0"
peerDependencies:
eslint: ">=7.0.0"
bin:
eslint-config-prettier: bin/cli.js
checksum: 10c0/6d332694b36bc9ac6fdb18d3ca2f6ac42afa2ad61f0493e89226950a7091e38981b66bac2b47ba39d15b73fff2cd32c78b850a9cf9eed9ca9a96bfb2f3a2f10d
languageName: node
linkType: hard

"eslint-import-resolver-node@npm:^0.3.6, eslint-import-resolver-node@npm:^0.3.9":
version: 0.3.9
resolution: "eslint-import-resolver-node@npm:0.3.9"
Expand Down Expand Up @@ -1641,8 +1652,10 @@ __metadata:
autoprefixer: "npm:^10.0.1"
eslint: "npm:^8"
eslint-config-next: "npm:14.1.0"
eslint-config-prettier: "npm:^9.1.0"
next: "npm:14.1.0"
postcss: "npm:^8"
prettier: "npm:^3.2.5"
react: "npm:^18"
react-dom: "npm:^18"
tailwindcss: "npm:^3.3.0"
Expand Down Expand Up @@ -3118,6 +3131,15 @@ __metadata:
languageName: node
linkType: hard

"prettier@npm:^3.2.5":
version: 3.2.5
resolution: "prettier@npm:3.2.5"
bin:
prettier: bin/prettier.cjs
checksum: 10c0/ea327f37a7d46f2324a34ad35292af2ad4c4c3c3355da07313339d7e554320f66f65f91e856add8530157a733c6c4a897dc41b577056be5c24c40f739f5ee8c6
languageName: node
linkType: hard

"proc-log@npm:^3.0.0":
version: 3.0.0
resolution: "proc-log@npm:3.0.0"
Expand Down
8 changes: 7 additions & 1 deletion taskfiles/frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,10 @@ tasks:
install:
dir: frontend
cmds:
- yarn install
- corepack enable
- corepack use yarn@stable
- yarn
update:
dir: frontend
cmds:
- yarn upgrade

0 comments on commit a58a5f0

Please sign in to comment.