Skip to content

Commit

Permalink
combine nss and libcal in to a monorepo (#39)
Browse files Browse the repository at this point in the history
* make a monorepo ...

* remove .idea
  • Loading branch information
francojreyes authored Mar 28, 2024
1 parent 9e893db commit 28697a0
Show file tree
Hide file tree
Showing 50 changed files with 2,391 additions and 197 deletions.
30 changes: 20 additions & 10 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ on:

jobs:
test:
name: "Test"
name: "Test (${{ matrix.scraper }})"
runs-on: ubuntu-latest
strategy:
fail-fast: true
max-parallel: 1
matrix:
scraper: [ nss, libcal ]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
Expand All @@ -21,9 +26,13 @@ jobs:
HASURAGRES_URL: https://graphql.csesoc.app
HASURAGRES_API_KEY: ${{ secrets.HASURAGRES_API_KEY }}
build:
name: "Build"
needs: [test]
name: "Test (${{ matrix.scraper }})"
needs: [ test ]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
scraper: [ nss, libcal ]
permissions:
contents: read
packages: write
Expand All @@ -45,10 +54,10 @@ jobs:
with:
push: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }}
platforms: linux/amd64
file: Dockerfile
file: ${{ matrix.scraper }}.dockerfile
tags: |
ghcr.io/devsoc-unsw/nss-scraper:${{ github.sha }}
ghcr.io/devsoc-unsw/nss-scraper:latest
ghcr.io/devsoc-unsw/${{ matrix.scraper }}-scraper:${{ github.sha }}
ghcr.io/devsoc-unsw/${{ matrix.scraper }}-scraper:latest
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
Expand All @@ -73,11 +82,12 @@ jobs:
git config user.name "CSESoc CD"
git config user.email "[email protected]"
git checkout -b update/nss-scraper/${{ github.sha }}
git checkout -b update/freerooms-scrapers/${{ github.sha }}
yq -i '.spec.jobTemplate.spec.template.spec.containers[0].image = "ghcr.io/devsoc-unsw/nss-scraper:${{ github.sha }}"' projects/nss-scraper/nss-scraper.yml
yq -i '.spec.jobTemplate.spec.template.spec.containers[0].image = "ghcr.io/devsoc-unsw/libcal-scraper:${{ github.sha }}"' projects/libcal-scraper/libcal-scraper.yml
git add .
git commit -m "feat(nss-scraper): update image"
git push -u origin update/nss-scraper/${{ github.sha }}
gh pr create -B migration --title "feat(nss-scraper): update image" --body "Updates the image for the nss-scraper deployment to commit devsoc-unsw/nss-scraper@${{ github.sha }}." > URL
git commit -m "feat(freerooms-scrapers): update images"
git push -u origin update/freerooms-scrapers/${{ github.sha }}
gh pr create -B migration --title "feat(freerooms-scrapers): update images" --body "Updates the images for the nss-scraper and libcal-scraper deployments to commit devsoc-unsw/freerooms-scrapers@${{ github.sha }}." > URL
gh pr merge $(cat URL) --squash -d
137 changes: 1 addition & 136 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,136 +1 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
database.json

# artifacts
bookings.json
buildings.json
rooms.json
.idea/**
21 changes: 0 additions & 21 deletions Dockerfile

This file was deleted.

11 changes: 0 additions & 11 deletions docker-compose.yaml

This file was deleted.

28 changes: 28 additions & 0 deletions libcal.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM node:20.11.1-alpine as builder
WORKDIR /app

# Install dependencies
COPY libcal/package.json libcal/package-lock.json ./
RUN npm ci

# Transpile
COPY libcal/src ./src
COPY libcal/tsconfig.json ./
RUN npm run build

FROM node:20.11.1-alpine as runner
ENV NODE_ENV production
WORKDIR /app

# Install production dependencies
COPY libcal/package.json nss/package-lock.json ./
RUN npm ci

# Copy expected file structures
# sql should be in working directory of project
# Root sql should be sibling of project directory
COPY --from=builder /app/dist ./dist
COPY nss/sql ./sql
COPY sql ../

CMD npm start
2 changes: 2 additions & 0 deletions libcal/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
HASURAGRES_URL=http://localhost:8000
HASURAGRES_API_KEY=my_key
128 changes: 128 additions & 0 deletions libcal/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
database.json

# artifacts
bookings.json
buildings.json
rooms.json
Loading

0 comments on commit 28697a0

Please sign in to comment.