Skip to content

Commit

Permalink
Merge pull request #41 from Code-Hammers/dev
Browse files Browse the repository at this point in the history
Merging Dev to Main
  • Loading branch information
brok3turtl3 authored Mar 14, 2024
2 parents b4f0eb4 + f02945e commit d2aa24f
Show file tree
Hide file tree
Showing 58 changed files with 5,113 additions and 449 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
npm-debug.log
23 changes: 23 additions & 0 deletions .github/workflows/build-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: build-tests
on:
pull_request:
branches:
- dev
jobs:
unit-testing:
runs-on: ubuntu-latest
env:
JWT_SECRET: ${{ secrets.JWT_SECRET }}
steps:
- uses: actions/checkout@v3
- name: Build Docker Image
run: docker build -t brok3turtl3/codehammers:latest -f Dockerfile-dev .
- name: Install Root Dependencies
run: docker run brok3turtl3/codehammers:latest npm install
- name: Install Client Dependencies
run: docker run brok3turtl3/codehammers:latest /bin/sh -c "cd client && npm install"
#- name: List node_modules
#run: docker run brok3turtl3/codehammers:latest /bin/sh -c "ls node_modules && cd client && ls node_modules"
- run: docker-compose -f docker-compose-test.yml up --abort-on-container-exit
env:
JWT_SECRET: ${{ secrets.JWT_SECRET }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
.env
dist/
coverage/
coverage/
/client/build/
30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#SET NODE VERSION
FROM node:18.17.1 as builder

#CONTAINER WORKING DIRECTORY
WORKDIR /usr/src/app

#COPY FILES INTO CONTAINER AT /usr/src/app
COPY . .

#INSTALL ROOT PACKAGES
RUN npm install

#INSTALL CLIENT PACKAGES
RUN cd client && npm install && npm run build

#SERVE BUILT FILES
FROM node:18.17.1

#SET WORKING DIRECTORY
WORKDIR /usr/src/app

#COPY FROM BUILDER STAGE
COPY --from=builder /usr/src/app/client/build ./client/build
COPY --from=builder /usr/src/app/node_modules ./node_modules

#EXPOSE PORT
EXPOSE 80

#DEFAULT CMD TO SERVE BUILT FILES
CMD ["npx", "serve", "-s", "client/build", "-l", "80"]
21 changes: 21 additions & 0 deletions Dockerfile-dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#SET NODE VERSION
FROM node:18.17.1

#CONTAINER WORKING DIRECTORY
WORKDIR /usr/src/app

#COPY FILES INTO CONTANER AT /usr/src/app
COPY . .

#TYING TO EXPLICITLY COPY THE CLIENT FOLDER
COPY ./client /usr/src/app/client

#INSTALL ROOT PACKAGES
RUN npm install

#INSTAL CLIENT PACKAGES
RUN cd client && npm install

#EXPOSE THE WEBPACK-DEV-SERVER PORT
EXPOSE 3000

31 changes: 31 additions & 0 deletions PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Thank you for your contribution to Code Hammers's repository! Before merging, please fill out this brief form.

### Description

(What does this PR do? What problem does it solve? What feature does it add? What is the impact of this change? What other PRs does this depend on? If this PR is a work in progress, please add the `WIP` label.)

### Jira Task

(**Replace this text** with a link to your Jira task link here, or N/A)

### Testing Instructions

_**Note:** this does not mean pasting in how to run the Jest tests. Let us know if there is a specific flow we need to follow to test the fuctionality on the site itself, or if there is a specific page you want to test, etc. This is not needed for most PRs._

### Checklist

Please go through each item of this checklist carefully.

- [x] (Example checked item. Don't add any spaces around the "x".)

#### All Team Members

- [ ] I added a descriptive title to this PR.
- [ ] I filled out the **Description**, **Jira Task**, and **Testing Instructions** sections above.
- [ ] I added or updated [Jest unit tests]for any changes to components, server-side controllers, etc.
- [ ] I ran `npm run docker-test` in my local environment to check that this PR passes all unit tests.
- [ ] I did a quick check to make sure my code changes follow the recomended style guide.

### Additional Notes, Images, etc.

(This is space for any additional information or attachments you'd like to add as part of this PR.)
6 changes: 5 additions & 1 deletion TODOS_GENERAL
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Review and refactor error handling.
# Review and refactor error handling. Needs to be more consistent. Need a guidelines section.

# Review types (Do we need separate types? Will this cause issues later on?)

# Add much more thorough edge case tetsing on test files.

# Create a shared types environment for front and back.

# Create User types for front end
33 changes: 14 additions & 19 deletions __tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,22 @@ afterAll(async () => {
});

describe("API Endpoints", () => {
it("should get the API Running message in development", async () => {
xit("should get the API Running message in development", async () => {
const res = await request(app).get("/api");
expect(res.statusCode).toEqual(200);
expect(res.body).toHaveProperty("message", "API Running - Hazzah!");
});

it("should serve the frontend files in production", async () => {
xit("should serve the frontend files in production", async () => {
process.env.NODE_ENV = "production";

const res = await request(app).get("/");
expect(res.statusCode).toEqual(200);

expect(res.headers["content-type"]).toContain("text/html");
});

it("should catch all routes and serve the frontend in production", async () => {
xit("should catch all routes and serve the frontend in production", async () => {
process.env.NODE_ENV = "production";
const res = await request(app).get("/nonexistentroute");
expect(res.statusCode).toEqual(200);
Expand All @@ -52,28 +53,22 @@ describe("Server Start-Up", () => {
const originalLog = console.log;
const logCalls: string[] = [];
console.log = jest.fn((...args: any[]) => {
logCalls.push(args.join(' '));
logCalls.push(args.join(" "));
});

jest.resetModules();
await new Promise(resolve => {

await new Promise((resolve) => {
if (server) {
server.on('listening', resolve);
server.on("listening", resolve);
}
});

const hasExpectedLog = logCalls.some(log => log.includes("Server running in"));

const hasExpectedLog = logCalls.some((log) =>
log.includes("Server running in")
);
expect(hasExpectedLog).toBe(true);

console.log = originalLog;
});
});








Loading

0 comments on commit d2aa24f

Please sign in to comment.