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

Frontend versioning #8

Merged
merged 8 commits into from
Feb 4, 2024
Merged
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
79 changes: 53 additions & 26 deletions .github/workflows/fullstack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@ jobs:
run: cd backend && yarn lint
- name: Test
run: cd backend && TEST_MONGODB_URI=${{ secrets.TEST_MONGODB_URI }} SECRET=${{ secrets.SECRET }} yarn test
frontend_test_and_fullstack_deployment:
- name: Test Failure
uses: BubbleProd/discord-webhook-notify@v2
if: failure()
with:
severity: error
details: Pipeline failed
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }}
frontend_tests:
runs-on: ubuntu-20.04
needs:
- backend_workflow
Expand All @@ -46,40 +53,60 @@ jobs:
run: cd frontend && yarn build
- name: Test
run: cd frontend && yarn test
- name: Test e2e
uses: cypress-io/github-action@v5
with:
command: cd frontend && yarn test:e2e
start: cd backend && yarn start:test
wait-on: http://localhost:3001
browser: chrome
record: true
- name: Deploy to production
id: deploy
env:
COMMIT_MESSAGES: ${{ join(github.event.commits.*.message, ' ') }}
if: ${{ github.event_name == 'push' && !contains(env.COMMIT_MESSAGES, '#skip') }}
uses: johnbeynon/[email protected]
with:
service-id: ${{ secrets.RENDER_SERVICE_ID }}
api-key: ${{ secrets.RENDER_API_KEY }}
- name: Test Failure
uses: BubbleProd/discord-webhook-notify@v2
if: failure()
with:
severity: error
details: Pipeline failed
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }}
- name: Test Failure at Deploy
uses: BubbleProd/discord-webhook-notify@v2
if: ${{ steps.deploy.conclusion == 'failure' }}
with:
severity: error
details: ${{ steps.deploy.outputs.message }}
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }}
e2e-tests_and_deploy:
runs-on: ubuntu-20.04
needs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install frontend and backend packages
run: cd frontend && yarn install && cd ../backend && yarn install
- name: Start server
run: yarn start:test-background
working-directory: ./backend
- name: wait for server
run: yarn wait-on http://localhost:3001
- name: E2E Tests
uses: cypress-io/github-action@v5
with:
working-directory: ./frontend
command: yarn test:e2e
wait-on: http://localhost:3001
browser: chrome
record: true
- name: Deploy to production
id: deploy
env:
COMMIT_MESSAGES: ${{ join(github.event.commits.*.message, ' ') }}
if: ${{ github.event_name == 'push' && !contains(env.COMMIT_MESSAGES, '#skip') }}
uses: johnbeynon/[email protected]
with:
service-id: ${{ secrets.RENDER_SERVICE_ID }}
api-key: ${{ secrets.RENDER_API_KEY }}
- name: Test Failure
uses: BubbleProd/discord-webhook-notify@v2
if: failure()
with:
severity: error
details: Pipeline failed
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }}
- name: Test Failure at Deploy
uses: BubbleProd/discord-webhook-notify@v2
if: ${{ steps.deploy.conclusion == 'failure' }}
with:
severity: error
details: ${{ steps.deploy.outputs.message }}
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }}
tag_release:
if: ${{ github.event_name == 'push' && !contains(join(github.event.commits.*.message, ' '), '#skip') }}
needs: frontend_test_and_fullstack_deployment
needs: e2e-tests_and_deploy
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
Expand Down
3 changes: 2 additions & 1 deletion backend/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/
.env
dist/
.env
104 changes: 0 additions & 104 deletions backend/dist/assets/index-052b101e.js

This file was deleted.

5 changes: 0 additions & 5 deletions backend/dist/assets/index-1db55104.css

This file was deleted.

15 changes: 0 additions & 15 deletions backend/dist/index.html

This file was deleted.

8 changes: 5 additions & 3 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
"main": "index.js",
"license": "MIT",
"scripts": {
"start": "cross-env NODE_ENV=production ts-node src/index.ts",
"start:test": "cross-env NODE_ENV=test ts-node src/index.ts",
"dev": "cross-env NODE_ENV=development nodemon src/index.ts",
"test": "cross-env NODE_ENV=test jest --verbose --runInBand",
"build:frontend": "cd ../frontend && yarn build && cp -r dist ../backend",
"lint": "eslint ."
"lint": "eslint .",
"start": "yarn build:frontend && cross-env NODE_ENV=production ts-node src/index.ts",
"start:test": "yarn build:frontend && cross-env NODE_ENV=test ts-node src/index.ts",
"start:test-background": "yarn start:test &"
},
"dependencies": {
"bcrypt": "^5.1.0",
Expand Down Expand Up @@ -39,6 +40,7 @@
"concurrently": "^8.2.2",
"cross-env": "^7.0.3",
"eslint": "^8.44.0",
"forever": "^4.0.3",
"jest": "^29.6.0",
"ngrok": "^5.0.0-beta.2",
"nodemon": "^2.0.22",
Expand Down
13 changes: 7 additions & 6 deletions backend/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,8 @@ const startApp = async () => {
app.use(middleware.requestLogger);
app.use(middleware.tokenExtractor);

app.get("/", (req, res) => {
res.sendFile("index.html", { root: "dist" });
});

app.get("/users", (req, res) => {
res.sendFile("index.html", { root: "dist" });
app.get("/blogs", (req, res) => {
res.redirect("/");
});

app.get("/health-check", (req, res) => {
Expand All @@ -46,6 +42,11 @@ const startApp = async () => {
if (process.env.NODE_ENV === "test") {
app.use("/api/testing", testingRouter);
}

app.get("*", (req, res) => {
res.sendFile("index.html", { root: "dist" });
});

app.use(middleware.unknownEndpoint);
app.use(middleware.errorHandler);

Expand Down
Loading