Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/cloc-2.11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
renatodellosso authored Nov 15, 2024
2 parents bf0ac42 + 730c758 commit 302e502
Show file tree
Hide file tree
Showing 68 changed files with 3,437 additions and 2,738 deletions.
1 change: 1 addition & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NEXT_PUBLIC_API_URL=http://localhost:3000/api
25 changes: 0 additions & 25 deletions .github/workflows/build.yml

This file was deleted.

76 changes: 76 additions & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: CI/CD

on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch: # Allows manual triggering of the workflow

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and export
uses: docker/build-push-action@v6
with:
tags: ghcr.io/decatur-robotics/gearbox:latest
outputs: type=docker,dest=/tmp/gearbox.tar

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: gearbox
path: /tmp/gearbox.tar

unit_test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20'

- name: Install dependencies
run: npm install

- name: Unit Tests
run: npm run test

push_to_ghcr:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
needs:
- build
- unit_test
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Download artifact
uses: actions/download-artifact@v4
with:
name: gearbox
path: /tmp

- name: Load image
run: |
docker load --input /tmp/gearbox.tar
docker image ls -a
- name: Sign in to GHCR
run: echo "${{ secrets.GHCR_TOKEN }}" | docker login ghcr.io -u decatur-robotics --password-stdin

- name: Push to GHCR
run: docker push ghcr.io/decatur-robotics/gearbox:latest
25 changes: 0 additions & 25 deletions .github/workflows/unittest.yml

This file was deleted.

6 changes: 6 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recommendations": [
"ms-azuretools.vscode-docker",
"formulahendry.docker-explorer"
]
}
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM node:20

LABEL org.opencontainers.image.source=https://github.com/Decatur-Robotics/Gearbox
LABEL org.opencontainers.image.description="Gearbox"
LABEL org.opencontainers.image.licenses=CC-BY-NC-SA-4.0

WORKDIR /app

COPY package*.json ./
RUN npm i

COPY . .

RUN npm run build

EXPOSE 443

CMD npm run start

Check warning on line 18 in Dockerfile

View workflow job for this annotation

GitHub Actions / build

JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals

JSONArgsRecommended: JSON arguments recommended for CMD to prevent unintended behavior related to OS signals More info: https://docs.docker.com/go/dockerfile/rule/json-args-recommended/
10 changes: 6 additions & 4 deletions components/Container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ReactNode, useEffect, useState } from "react";
import { BiMenu, BiPlus, BiHome, BiSolidPhone } from "react-icons/bi";
import { IoSunny, IoMoon, IoCloudOffline } from "react-icons/io5";
import { BsGearFill } from "react-icons/bs";
import ClientAPI from "@/lib/client/ClientAPI";
import ClientApi from "@/lib/api/ClientApi";
import Footer from "./Footer";
import { FaDiscord, FaSearch } from "react-icons/fa";
import useCheckMobile from "@/lib/client/useCheckMobile";
Expand All @@ -18,7 +18,7 @@ import useIsOnline from "@/lib/client/useIsOnline";
import { forceOfflineMode } from "@/lib/client/ClientUtils";
import Head from "next/head";

const api = new ClientAPI("gearboxiscool");
const api = new ClientApi();

type ContainerProps = {
children: ReactNode;
Expand Down Expand Up @@ -111,7 +111,9 @@ export default function Container(props: ContainerProps) {
}

for (const season of selectedTeam?.seasons) {
newSeasons.push(await api.findSeasonById(season));
const seasonObj = await api.findSeasonById(season).catch(() => undefined);
if (seasonObj)
newSeasons.push(seasonObj);
}

setSelectedTeamSeasons(newSeasons);
Expand Down Expand Up @@ -317,7 +319,7 @@ export default function Container(props: ContainerProps) {
"w-16 h-16 btn btn-ghost " +
(selected ? "border-2 border-accent" : "border-2")
}
key={team._id}
key={team._id.toString()}
onClick={() => {
setSelectedTeamIndex(index);
}}
Expand Down
6 changes: 3 additions & 3 deletions components/PitReport.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ClientAPI from "@/lib/client/ClientAPI";
import ClientApi from "@/lib/api/ClientApi";
import { useCurrentSession } from "@/lib/client/useCurrentSession";
import { FormLayout, FormElement, BlockElement } from "@/lib/Layout";
import { AllianceColor, FieldPos, Game, Pitreport, PitReportData } from "@/lib/Types";
Expand All @@ -16,7 +16,7 @@ import { camelCaseToTitleCase } from "@/lib/client/ClientUtils";
import FieldPositionSelector from "./forms/FieldPositionSelector";
import { GameId } from "@/lib/client/GameId";

const api = new ClientAPI("gearboxiscool");
const api = new ClientApi();

export default function PitReportForm(props: { pitReport: Pitreport, layout: FormLayout<PitReportData>, compId?: string,
usersteamNumber?: number, compName?: string, username?: string, game: Game }) {
Expand All @@ -41,7 +41,7 @@ export default function PitReportForm(props: { pitReport: Pitreport, layout: For
const { _id, ...report } = pitreport;

console.log("Submitting pitreport", report);
api.updatePitreport(props.pitReport?._id, {
api.updatePitreport(props.pitReport?._id!, {
...report,
submitted: true,
submitter: session?.user?._id
Expand Down
6 changes: 3 additions & 3 deletions components/SubjectiveReportForm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ClientAPI from "@/lib/client/ClientAPI";
import ClientApi from "@/lib/api/ClientApi";
import { updateCompInLocalStorage } from "@/lib/client/offlineUtils";
import { useCurrentSession } from "@/lib/client/useCurrentSession";
import useInterval from "@/lib/client/useInterval";
Expand All @@ -12,7 +12,7 @@ import QRCode from "react-qr-code";
import { Analytics } from "@/lib/client/Analytics";
import QrCode from "./QrCode";

const api = new ClientAPI("gearboxiscool");
const api = new ClientApi();

export default function SubjectiveReportForm(props: { match: Match, compId?: string, teamNumber?: number, compName?: string }) {
const router = useRouter();
Expand Down Expand Up @@ -69,7 +69,7 @@ export default function SubjectiveReportForm(props: { match: Match, compId?: str
return;
}

api.submitSubjectiveReport(getReportFromForm(), session?.session?.user?._id!, teamSlug as string)
api.submitSubjectiveReport(getReportFromForm(), teamSlug as string)
.catch((err) => {
console.error(err);

Expand Down
2 changes: 1 addition & 1 deletion components/TeamCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default function TeamCard(props: { team: Team | undefined }) {
return (
<Card
title={team?.name}
key={team?._id}
key={team?._id.toString()}
className="w-full bg-base-300 border-4 border-base-300 transition ease-in hover:border-primary"
>
<h1 className="font-semibold max-sm:text-sm">
Expand Down
Loading

0 comments on commit 302e502

Please sign in to comment.