Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
WilcoApp committed Jul 13, 2024
1 parent 67c046d commit c421dd1
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 154 deletions.
40 changes: 1 addition & 39 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,42 +1,4 @@
{
"name": "Anythink Development Container",
"image": "public.ecr.aws/v0a2l7y2/wilco/anythink-devcontainer:latest",
"forwardPorts": [3000, 3001, 5433, 27017],
"portsAttributes": {
"3000": {
"label": "Backend",
"elevateIfNeeded": true,
"requireLocalPort": true,
"onAutoForward": "silent"
},
"3001": {
"label": "Frontend",
"elevateIfNeeded": true,
"requireLocalPort": true,
"onAutoForward": "silent"
},
"5433": {
"label": "Database",
"elevateIfNeeded": true,
"requireLocalPort": true,
"onAutoForward": "silent"
},
"27017": {
"label": "Database",
"elevateIfNeeded": true,
"requireLocalPort": true,
"onAutoForward": "silent"
}
},
"postStartCommand": "bash -c .devcontainer/setup.sh",

"settings": {
"extensions.ignoreRecommendations": true,
"workbench.startupEditor": "none",
"workbench.colorTheme": "Visual Studio Dark",
"workbench.colorCustomizations": {},
"workbench.welcomePage.walkthroughs.openOnInstall": false,
"workbench.welcomePage.experimental.videoTutorials": "off",
"github.codespaces.defaultExtensions": []
}
"image": "public.ecr.aws/v0a2l7y2/wilco/anythink-devcontainer:latest"
}
29 changes: 0 additions & 29 deletions .devcontainer/open_port.sh

This file was deleted.

17 changes: 5 additions & 12 deletions .devcontainer/setup.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
WILCO_ID="`cat .wilco`"
ENGINE_EVENT_ENDPOINT="${ENGINE_BASE_URL}/users/${WILCO_ID}/event"
CODESPACE_BACKEND_HOST="${CODESPACE_NAME}-3000.preview.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}"
CODESPACE_BACKEND_HOST=$(curl -s "${ENGINE_BASE_URL}/api/v1/codespace/backendHost?codespaceName=${CODESPACE_NAME}&portForwarding=${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}" | jq -r '.codespaceBackendHost')
CODESPACE_BACKEND_URL="https://${CODESPACE_BACKEND_HOST}"
export ENGINE_EVENT_ENDPOINT="${ENGINE_BASE_URL}/users/${WILCO_ID}/event"

# Update engine that codespace started for user
curl -L -X POST "${ENGINE_EVENT_ENDPOINT}" -H "Content-Type: application/json" --data-raw "{ \"event\": \"github_codespace_started\" }"
Expand All @@ -11,15 +11,8 @@ echo "export CODESPACE_BACKEND_HOST=\"${CODESPACE_BACKEND_HOST}\"" >> ~/.bashrc
echo "export CODESPACE_BACKEND_URL=\"${CODESPACE_BACKEND_URL}\"" >> ~/.bashrc
echo "export CODESPACE_WDS_SOCKET_PORT=443" >> ~/.bashrc


# Change backend port visibility to public
echo "(&>/dev/null .devcontainer/open_port.sh &)" >> ~/.bashrc


# Export welcome prompt in bash:
echo "printf \"\n\n☁️☁️☁️️ Anythink: Develop in the Cloud ☁️☁️☁️\n\"" >> ~/.bashrc
echo "printf \"\n=============================================\n\"" >> ~/.bashrc
echo "gh codespace ports -c $CODESPACE_NAME" >> ~/.bashrc
echo "printf \"=============================================\n\"" >> ~/.bashrc
echo "printf \"(Once docker-compose is up and running, you can access the frontend and backend using the above urls)\n\"" >> ~/.bashrc
echo "printf \"\n\x1b[31m \x1b[1m👉 Type: \\\`docker-compose up\\\` to run the project. 👈\n\n\"" >> ~/.bashrc
echo "printf \"\n\x1b[31m \x1b[1m👉 Type: \\\`docker compose up\\\` to run the project. 👈\n\n\"" >> ~/.bashrc

nohup bash -c "cd /wilco-agent && node agent.js &" >> /tmp/agent.log 2>&1
12 changes: 0 additions & 12 deletions anythink_ack.sh

This file was deleted.

9 changes: 4 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,10 @@ services:
- '27017:27017'

anythink-ack:
build: ./frontend
image: public.ecr.aws/v0a2l7y2/wilco/anythink-ack:latest
container_name: anythink-ack
command: sh -c "/wait-for-it.sh anythink-frontend-react:3001 -q -t 1000 && ./anythink_ack.sh"
working_dir: /usr/src
volumes:
- ./:/usr/src/
environment:
- GITHUB_TOKEN=$GITHUB_TOKEN
- CODESPACE_NAME=$CODESPACE_NAME
depends_on:
- "anythink-frontend-react"
8 changes: 2 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ When implementing a new feature or fixing a bug, please create a new pull reques
## How to run in dev mode?

### Using Codespace
1. run `docker-compose up`
### On your local machine
1. [Install Docker](https://docs.docker.com/get-docker/)
2. [Install Docker Compose](https://docs.docker.com/compose/install/)
3. Run `docker-compose up`.
1. run `docker compose up`

## Tests
Documentation about running the End to End test can be found under the `/tests` directory
Documentation about running the End to End test can be found under the `/tests` directory
44 changes: 0 additions & 44 deletions start_quest.sh

This file was deleted.

2 changes: 1 addition & 1 deletion tests/e2e/anytinkClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class AnythinkClient {
constructor() {
this.client = axios.create({
baseURL: "http://localhost:3000",
timeout: 2000,
timeout: 10000,
});
}

Expand Down
12 changes: 6 additions & 6 deletions tests/e2e/concurrent/items.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ describe("Items Route", () => {
})
).toBe(true);

const retreivedItem = await anythinkClient.getItem(item.slug);
expect(matchObjects(retreivedItem, updatedItemResult)).toBe(true);
const retrievedItem = await anythinkClient.getItem(item.slug);
expect(matchObjects(retrievedItem, updatedItemResult)).toBe(true);
};
});

Expand Down Expand Up @@ -265,17 +265,17 @@ describe("Items Route", () => {
).rejects.toThrow();
});

test("Comments are retreived in reversed order", async () => {
test("Comments are retrieved in reversed order", async () => {
const item = await anythinkClient.createItem(randomItemInfo(), user);
const commnets = await addComments(item, [
const comments = await addComments(item, [
commentingUserA,
commentingUserB,
]);

const itemsComments = await anythinkClient.getComments(item.slug);

expect(itemsComments[0]).toMatchObject(commnets[1]);
expect(itemsComments[1]).toMatchObject(commnets[0]);
expect(itemsComments[0]).toMatchObject(comments[1]);
expect(itemsComments[1]).toMatchObject(comments[0]);
});

test("Users can delete their own comments", async () => {
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/jest.concurrent.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ module.exports = {
testPathIgnorePatterns: ["/node_modules/", "/sequential/"],
globalSetup: "<rootDir>/setup.js",
globalTeardown: "<rootDir>/teardown.js",
testTimeout: 30000,
};

0 comments on commit c421dd1

Please sign in to comment.