Skip to content

Commit

Permalink
Merge pull request #90 from sbv-world-health-org-metrics/ajhenry/ts-b…
Browse files Browse the repository at this point in the history
…ackend

Update metrics fetcher to use a Typescript-based pipeline
  • Loading branch information
ajhenry authored Feb 5, 2024
2 parents ad4d300 + 79f35ed commit 7b41984
Show file tree
Hide file tree
Showing 20 changed files with 7,496 additions and 47 deletions.
25 changes: 6 additions & 19 deletions .github/workflows/nextjs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,13 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go 1.x
uses: actions/setup-go@v4
- name: Fetch Metrics
uses: actions/setup-node@v4
with:
go-version: ^1.19
- name: Get dependencies
run: |
cd backend
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
- name: Build Go
run: make build
# - name: Test
# run: make test
- name: Run Go program and save output
id: run
node-version: "20.x"
run: |
$PWD/backend/bin/metrics
npm i
npm start
- name: Detect package manager
id: detect-package-manager
run: |
Expand All @@ -76,7 +63,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "16"
node-version: "20.x"
cache: ${{ steps.detect-package-manager.outputs.manager }}
cache-dependency-path: ${{ steps.detect-package-manager.outputs.cache-dependency-path }}
- name: Setup Pages
Expand Down
38 changes: 23 additions & 15 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch metrics (local)",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}/backend/cmd/main.go",
"envFile": "${workspaceFolder}/dev.vscode.env",
},
]
}
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch metrics (local)",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}/backend/cmd/main.go",
"envFile": "${workspaceFolder}/dev.vscode.env"
},
{
"name": "Next.js: debug metrics",
"type": "node-terminal",
"request": "launch",
"cwd": "${workspaceFolder}/ts-backend",
"command": "npm run start",
"envFile": "${workspaceFolder}/ts-backend/.env"
}
]
}
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ Issue Project [here](https://github.com/github/SI-skills-based-volunteering/iss
## Development in Codespaces

<!-- TODO: Add min requirements and deployment steps -->
### Backend
### Go Backend

To update the repository data.
To update the repository data using the Go backend

1. Generate a [new GitHub Token](https://github.com/settings/tokens) with the ability to read repo, read org, and read projects scopes.
1. Set the `GRAPHQL_TOKEN` environment variable to be the value of your newly created token.
Expand All @@ -75,7 +75,16 @@ make build
./backend/bin/metrics
```

This will generate a new `data.json` file in the UI directory which can be imported directly as part of the static build.
This will generate a new `data.json` file in the UI directory which can be imported directly as part of the static build.\

### TypeScript Backend

To update the repository data using the TypeScript backend.

1. Generate a [new GitHub Token](https://github.com/settings/tokens) with the ability to read repo, read org, and read projects scopes.
1. Set the `GRAPHQL_TOKEN` environment variable to be the value of your newly created token.
1. `cd ts-backend && npm install && yarn start`. This will generate a `data.json` file in the `who-metrics-ui` directory.
1. `cd ../who-metrics-ui` and run `npm install && npm run dev` to start the server.

### UI

Expand Down
2 changes: 2 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
organization: "WorldHealthOrganization"
1 change: 1 addition & 0 deletions ts-backend/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GRAPHQL_TOKEN=your_token
12 changes: 12 additions & 0 deletions ts-backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.cache
.DS_Store
.idea
*.log
*.tgz
coverage
dist
lib-cov
logs
node_modules
temp
*data.json
12 changes: 12 additions & 0 deletions ts-backend/build.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { defineBuildConfig } from 'unbuild'

export default defineBuildConfig({
entries: [
'src/index',
],
declaration: true,
clean: true,
rollup: {
emitCJS: true,
},
})
Loading

0 comments on commit 7b41984

Please sign in to comment.