Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing #699

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 9 additions & 23 deletions .github/workflows/cd-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: SSH into Hozer
uses: appleboy/[email protected]
with:
host: hozer-51.ocf.berkeley.edu
username: root
key: ${{ secrets.SSH_KEY }}
script: |
cd /berkeleytime
git checkout ${{ github.event.pull_request.head.sha }}
git pull
docker compose up --build -d
docker tag berkeleytime-backend octoberkeleytime/bt-backend:${{ github.event.pull_request.head.sha }}
docker tag berkeleytime-frontend octoberkeleytime/bt-frontend:${{ github.event.pull_request.head.sha }}
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker push octoberkeleytime/bt-backend:${{ github.event.pull_request.head.sha }}
docker push octoberkeleytime/bt-frontend:${{ github.event.pull_request.head.sha }}
helm install bt-dev-app ./app --namespace=bt \
--set host=${{ github.event.pull_request.head.sha }}.stanfurdtime.com \
--set mongoUri=mongodb://bt-dev-mongo-mongodb.bt.svc.cluster.local:27017/bt \
--set redisUri=redis://bt-dev-redis-master.bt.svc.cluster.local:6379 \
--set nodeEnv=development \
--set frontend.image.tag=${{ github.event.pull_request.head.sha }} \
--set backend.image.tag=${{ github.event.pull_request.head.sha }}
- name: Checkout Repository
uses: actions/checkout@v2

- name: Install SSH client
run: apt-get update && apt-get install -y openssh-client

- name: Run SSH command
run: |
ssh -i ${{ secrets.SSH_KEY }} [email protected] "echo test"
16 changes: 8 additions & 8 deletions .github/workflows/cd-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: SSH into Hozer
uses: appleboy/[email protected]
with:
host: hozer-51.ocf.berkeley.edu
username: root
key: ${{ secrets.SSH_KEY }}
script: |
- name: SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh -i ~/.ssh/id_rsa [email protected] << EOF
cd /berkeleytime
git checkout master
git pull
Expand All @@ -27,4 +26,5 @@ jobs:
docker push octoberkeleytime/bt-backend:latest
docker push octoberkeleytime/bt-frontend:latest
kubectl rollout restart deployment bt-staging-app-backend
kubectl rollout restart deployment bt-staging-app-frontend
kubectl rollout restart deployment bt-staging-app-frontend
EOF
14 changes: 7 additions & 7 deletions backend/src/scripts/update-catalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const SIS_SECTION_URL = 'https://gateway.api.berkeley.edu/sis/v1/classes/section

const semToTermId = (s: SemesterType) => {
// term-id is computed by dropping the century digit of the year, then adding the term code
const termMap: { [key: string] : number} = {'Fall': 8, 'Spring': 2, 'Summer': 5}
const termMap: { [key: string]: number } = { 'Fall': 8, 'Spring': 2, 'Summer': 5 }
return `${Math.floor(s.year / 1000)}${s.year % 100}${termMap[s.term]}`
}

Expand All @@ -31,21 +31,21 @@ const queryPages = async <T>(url: string, params: any, headers: any, field: stri
let resp: AxiosResponse<SISResponse<T>>;

try {
resp = await axios.get(url, { params: { 'page-number': page, ...params}, headers });
resp = await axios.get(url, { params: { 'page-number': page, ...params }, headers });
} catch (err) {
if (axios.isAxiosError(err) && err.response?.status === 404) {
break;
} else {
console.log(`Unexpected err querying SIS API. Error: ${err}.`)

if (retries > 0) {
retries--;
console.log(`Retrying...`)
continue;
} else {
console.log(`Too many errors querying SIS API for courses. Terminating update...`)
throw err;
}
}
}
}

Expand All @@ -71,7 +71,7 @@ const updateCourses = async () => {
const courses = await queryPages<CourseType>(SIS_COURSE_URL, params, headers, 'courses');

console.log("Updating database with new course data...")

const bulkOps = courses.map(c => ({
replaceOne: {
filter: { classDisplayName: c.classDisplayName },
Expand All @@ -95,7 +95,7 @@ const updateClasses = async () => {

const activeSemesters = await SemesterModel.find({ active: true }).lean();
const classes: ClassType[] = [];

for (const s of activeSemesters) {
console.log(`Updating classses for ${s.term} ${s.year}...`)

Expand Down Expand Up @@ -132,7 +132,7 @@ const updateSections = async () => {

const activeSemesters = await SemesterModel.find({ active: true }).lean();
const sections: SectionType[] = [];

for (const s of activeSemesters) {
console.log(`Updating sections for ${s.term} ${s.year}...`)

Expand Down
2 changes: 1 addition & 1 deletion infra/app/templates/backend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ spec:
ports:
- protocol: TCP
port: {{ .Values.port }}
targetPort: {{ .Values.backend.port }}
targetPort: {{ .Values.backend.port }}