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

Main update with CI/CD #3

Merged
merged 46 commits into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
d76cf3a
changed from app structure to pages structure
Rafaelfferreira Apr 29, 2024
11830c5
added html and css to the project to make the frondent
Rafaelfferreira Apr 29, 2024
addcd3a
added relative paths to tsconfig.json
Rafaelfferreira Apr 29, 2024
3ac0a24
cleaned up tsconfig.json file
Rafaelfferreira May 1, 2024
11fa221
added eslint and editorconfig to file
Rafaelfferreira May 1, 2024
aedbb41
updated recommended extension suggestions
Rafaelfferreira May 1, 2024
5c35b73
created function handler to call the read function on GET requests
Rafaelfferreira May 1, 2024
5ef2d15
commented out static table rows and added dynamic ones (that are stil…
Rafaelfferreira May 2, 2024
8fb670b
rendered table rows based on the static data of last commit
Rafaelfferreira May 2, 2024
f873887
added fetch to home screen to load todos from the server
Rafaelfferreira May 4, 2024
9e8f2b7
added pagination and a repository to the project
Rafaelfferreira May 5, 2024
75ef575
added parsing function to make sure we're returning the correct type …
Rafaelfferreira May 5, 2024
d0e54fb
made the controller return pages according to the limit and made the …
Rafaelfferreira May 9, 2024
a222a62
created backend repository and started parsing query parameters from …
Rafaelfferreira May 9, 2024
4fe6917
fixed bug that added more ui items every time we updated the index fi…
Rafaelfferreira May 12, 2024
571b448
removed extraneous argument on arrow function
Rafaelfferreira May 12, 2024
8768048
implemented a local search on the app
Rafaelfferreira May 14, 2024
c5756ad
stopped using useState to track the first loading of the screen and r…
Rafaelfferreira May 14, 2024
219b3e8
started working on PUT request. Implemented server part + ui controller
Rafaelfferreira May 16, 2024
caaa81a
integrated with the backend by updating the ui repository to create n…
Rafaelfferreira May 19, 2024
84f626e
created PUT endpoint to toggle done status of todos on backend
Rafaelfferreira May 21, 2024
de6724a
implemented the toggleDone integration on the ui controller
Rafaelfferreira May 24, 2024
f80ea30
implemented delete functionality on the backend
Rafaelfferreira May 26, 2024
71c7ef2
implemented delete on the ui
Rafaelfferreira May 29, 2024
289a540
added cypress to projet to start doing tests
Rafaelfferreira May 31, 2024
607be60
finished writing test to add new todo using cypress
Rafaelfferreira Jun 2, 2024
79b81b9
created new v0 of ci pipeline
Rafaelfferreira Jun 17, 2024
e0bc7fa
fixed identation
Rafaelfferreira Jun 17, 2024
3bdb085
update lint code to download dependencies
Rafaelfferreira Jun 17, 2024
6b61aee
fixed typo
Rafaelfferreira Jun 17, 2024
0ebd162
updated eslint
Rafaelfferreira Jun 17, 2024
f3a8c05
Merge pull request #1 from Rafaelfferreira/ci-development
Rafaelfferreira Jun 18, 2024
ba76803
added job to run cypress
Rafaelfferreira Jun 18, 2024
335c3c6
Merge pull request #2 from Rafaelfferreira/cypressCI
Rafaelfferreira Jun 18, 2024
f42a791
integrated codebase with supabase db on the GET request
Rafaelfferreira Jun 23, 2024
a26898b
fixed pagination issues and added safeParsing to the server
Rafaelfferreira Jul 13, 2024
7ea86c9
integrated create and delete endpoints with supabase
Rafaelfferreira Jul 13, 2024
e1596b9
integrated toggle done endpoint with supabase
Rafaelfferreira Jul 13, 2024
09d6364
remove unecessary console.log
Rafaelfferreira Jul 13, 2024
17e2533
extracted supabase initialization to an external file
Rafaelfferreira Jul 13, 2024
d7e5941
fixed type issues and started working to deploy in vercel
Rafaelfferreira Jul 14, 2024
2109e3b
fixed url and added vercel github secrets
Rafaelfferreira Jul 14, 2024
6f4942f
updated workflow to force deploy
Rafaelfferreira Jul 14, 2024
005578a
added reference to org and project ID inside workflow file
Rafaelfferreira Jul 14, 2024
40c5dbe
removed unnecessary comment
Rafaelfferreira Jul 14, 2024
f2a7d95
remove unnecessary comment
Rafaelfferreira Jul 14, 2024
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
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = true
34 changes: 34 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module.exports = {
parser: "@typescript-eslint/parser",
env: {
browser: true,
es2021: true,
node: true,
},
// plugins: ["react", "prettier", "@typescript-eslint"],
plugins: ["react", "@typescript-eslint"],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:prettier/recommended",
],
overrides: [],
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
settings: {
react: {
version: "detect",
},
},
ignorePatterns: ["node_modules/", "cypress/"],
// Cherry of the Cake
rules: {
"prettier/prettier": 0,
"nonblock-statement-body-position": "off",
// "no-console": "error",
"react/no-unknown-property": ["error", { ignore: ["jsx", "global"] }],
},
};
28 changes: 28 additions & 0 deletions .github/workflows/continuous-delivery.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: "CD- Continuous Delivery"

# on:
# push:
# branches: [ main ]

on:
pull_request:
types: [opened, synchronize]

env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}

jobs:
deploy:
runs-on: ubuntu-latest
steps:
## [Common_CI_Steps]
- uses: actions/checkout@v3
## ===========================
- name: "Debug"
run: |
ls -la
- name: "Install Dependencies"
run: "npm install"
- name: "Deploy"
run: "npx vercel --prod --token=${{ secrets.VERCEL_TOKEN }} "
35 changes: 35 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: "CI - Continuous Integration"

on:
pull_request:
types: [opened, synchronize]

jobs:
lint:
runs-on: ubuntu-latest
steps:
## [Common_CI_Steps]
- uses: actions/checkout@v3
## ===========================
- name: "Debug"
run: |
ls -la
echo "Second command line!"
- name: "Install Dependencies"
run: "npm install"
- name: "Lint"
run: "npm run lint"
test:
runs-on: ubuntu-22.04
container:
image: "cypress/browsers:node-20.9.0-chrome-118.0.5993.88-1-ff-118.0.2-edge-118.0.2088.46-1"
options: --user 1001
steps:
## [Common_CI_Steps]
- uses: actions/checkout@v3

- name: "Install Dependencies"
run: "npm install "
## ===========================
- name: "Test"
run: "npm run test"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,4 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
.vercel
5 changes: 5 additions & 0 deletions .vercelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.github
.vscode
core
cypress
.env
7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"recommendations": [
"EditorConfig.EditorConfig",
"dbaeumer.vscode-eslint",
"github.vscode-github-actions"
]
}
3 changes: 0 additions & 3 deletions app/api/route.ts

This file was deleted.

11 changes: 0 additions & 11 deletions app/layout.tsx

This file was deleted.

3 changes: 0 additions & 3 deletions app/page.tsx

This file was deleted.

79 changes: 79 additions & 0 deletions core/crud.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import fs from "fs";
import { v4 as uuid } from "uuid";

// MARK: - CONSTANTS
const DB_FILE_PATH = "./core/db";

// MARK: - TYPES
type UUID = string;

type Todo = {
id: UUID;
date: string;
content: string;
done: boolean;
};

// MARK: - CRUD FUNCTIONS
export function create(content: string): Todo {
const todo: Todo = {
id: uuid(),
date: new Date().toISOString(),
content: content,
done: false,
};

const todos: Array<Todo> = [
...read(),
todo,
];

// salvar o content no sistema
fs.writeFileSync(DB_FILE_PATH, JSON.stringify({
todos,
"dogs": []
}, null, 2)); // Sync -> synchronous
return todo;
}

export function read(): Array<Todo> {
const dbString = fs.readFileSync(DB_FILE_PATH, "utf-8");
const db = JSON.parse(dbString || "{}");
if (!db.todos) {
return [];
}
return db.todos;
}

export function update(id: UUID, partialTodo: Partial<Todo>): Todo { // Partial<Todo> -> Partial is a built-in type that makes all properties of Todo optional
let updatedTodo;

const todos = read();
todos.forEach((currentItem) => {
const isToUpdate = currentItem.id === id;
if(isToUpdate) {
updatedTodo = Object.assign(currentItem, partialTodo); // Object.assign -> built-in function that copies all properties from the second object to the first object
}
});

fs.writeFileSync(DB_FILE_PATH, JSON.stringify({
todos,
}, null, 2));

if(!updatedTodo) {
throw new Error("Please provide another ID!")
}

return updatedTodo;
}

export function deleteById(id: UUID) {
const todos = read();

const todosWithoutDeleted = todos.filter((todo) => {
if(todo.id === id) { return false; }
return true;
});

fs.writeFileSync(DB_FILE_PATH, JSON.stringify({ todos: todosWithoutDeleted }, null, 2));
}
29 changes: 29 additions & 0 deletions core/db
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"todos": [
{
"id": "30c08ad9-cd30-4e5f-8fb9-b84cb358b9a5",
"date": "2024-04-27T22:31:07.560Z",
"content": "Primeira TODO",
"done": true
},
{
"id": "a49eb7da-9586-4646-b2d9-c365e84b261d",
"date": "2024-04-27T22:31:07.561Z",
"content": "Terceira TODO com novo content!",
"done": false
},
{
"id": "4613fcbf-2561-47c8-9021-30cb0a4e226f",
"date": "2024-05-16T01:36:18.008Z",
"content": "Next day task",
"done": true
},
{
"id": "c733e23e-37f7-4cc0-b765-a3de7a157345",
"date": "2024-05-19T20:32:49.395Z",
"content": "alo alo w brazil",
"done": false
}
],
"dogs": []
}
9 changes: 9 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineConfig } from "cypress";

export default defineConfig({
e2e: {
setupNodeEvents() {
// implement node event listeners here
},
},
});
Loading
Loading