diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 4ca54da..50c64a2 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,4 +1,4 @@ -name: CI (Linting, Testing, Building) +name: CI (Formatting/Linting, Testing, Building) on: push: @@ -8,7 +8,7 @@ on: jobs: lint: - name: Lint + name: Format runs-on: ubuntu-latest strategy: matrix: @@ -28,17 +28,37 @@ jobs: with: node-version: ${{ matrix.node-version }} - - name: Lint Go code - run: | - cd backend - go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest - golangci-lint run ./... + - name: Install Task + uses: arduino/setup-task@v1 + with: + version: 3.x + repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Format Frontend run: | + task build cd client - npm install - npm run format + npm run check + - name: Format Backend + run: | + task build + cd backend + be_format_output=$(go fmt ./...) + if [[ -n "$be_format_output" ]]; then + echo "$be_format_output" + echo "::error::Formatting issues found" + exit 1 + fi + - name: Lint Backend + run: | + task build + cd backend + be_lint_output=$(go vet ./...) + if [[ -n "$be_lint_output" ]]; then + echo "$be_lint_output" + echo "::error::Linting issues found" + exit 1 + fi test: name: Test @@ -87,6 +107,7 @@ jobs: - name: Run Go tests run: | + task build task test-all build: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5805b47..ded1a6f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,12 +6,19 @@ repos: - id: check-added-large-files - id: check-merge-conflict - id: end-of-file-fixer - exclude: 'backend/docs/' + exclude: "backend/docs/" - id: trailing-whitespace - id: no-commit-to-branch - args: ['--branch', 'main'] + args: ["--branch", "main"] + - repo: local + hooks: + - id: format + language: python + name: Run Format + entry: bash -c 'task format' - repo: https://github.com/commitizen-tools/commitizen rev: v3.13.0 hooks: - id: commitizen - stages: [commit-msg] + - id: commitizen-branch + stages: [push] diff --git a/Taskfile.yaml b/Taskfile.yaml index 394fb79..9464db8 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -7,7 +7,6 @@ tasks: npm install cd ../backend go mod tidy - go install . format: - | @@ -48,5 +47,5 @@ tasks: pre-commit: - | - pre-commit install + pre-commit install --hook-type commit-msg --hook-type pre-push --hook-type pre-commit pre-commit run --all-files diff --git a/backend/schema/files/routes.go b/backend/schema/files/routes.go index 13a4cc3..bfae7aa 100644 --- a/backend/schema/files/routes.go +++ b/backend/schema/files/routes.go @@ -65,4 +65,4 @@ func (pg *PgModel) UploadFileRoute(c *gin.Context) { } c.JSON(http.StatusOK, file) -} \ No newline at end of file +} diff --git a/backend/schema/files/transactions.go b/backend/schema/files/transactions.go index a90586a..72ad0ef 100644 --- a/backend/schema/files/transactions.go +++ b/backend/schema/files/transactions.go @@ -49,7 +49,7 @@ func UploadFile(pool *pgx.Conn, file models.File, data *multipart.FileHeader, re fmt.Println(err.Error()) return err } - + uploader := s3manager.NewUploader(sess) _, err = uploader.Upload(&s3manager.UploadInput{ Bucket: aws.String(AWS_BUCKET_NAME), @@ -68,4 +68,4 @@ func UploadFile(pool *pgx.Conn, file models.File, data *multipart.FileHeader, re } return nil -} \ No newline at end of file +} diff --git a/client/components/DocPickerButton.tsx b/client/components/DocPickerButton.tsx index fc6d1cc..bc9295b 100644 --- a/client/components/DocPickerButton.tsx +++ b/client/components/DocPickerButton.tsx @@ -3,7 +3,7 @@ import { View, Button, Text } from 'react-native'; import * as DocumentPicker from 'expo-document-picker'; import { uploadFile } from '../services/file'; -export default function DocPickerButton(){ +export default function DocPickerButton() { const [pickedDocument, setPickedDocument] = useState(null); const pickDocument = async () => { @@ -18,7 +18,7 @@ export default function DocPickerButton(){ // TODO get userID and groupID const userID = 0; const groupID = 0; - await uploadFile(result.assets[0], userID, groupID) + await uploadFile(result.assets[0], userID, groupID); } } catch (err) { console.log('err', err); @@ -31,4 +31,4 @@ export default function DocPickerButton(){ {pickedDocument && Picked Document: {pickedDocument}} ); -}; \ No newline at end of file +} diff --git a/client/package.json b/client/package.json index 70dab8c..1833c88 100644 --- a/client/package.json +++ b/client/package.json @@ -8,7 +8,8 @@ "android": "expo start --android", "ios": "expo start --ios", "web": "expo start --web", - "format": "prettier --write ." + "format": "prettier --write .", + "check": "prettier --check ." }, "dependencies": { "@fortawesome/fontawesome-svg-core": "^6.5.1", diff --git a/client/types/declaration.d.ts b/client/types/declaration.d.ts index 9038ebf..fed8d16 100644 --- a/client/types/declaration.d.ts +++ b/client/types/declaration.d.ts @@ -1,6 +1,6 @@ -declare module "*.svg" { - import React from "react"; - import { SvgProps } from "react-native-svg"; - const content: React.FC; - export default content; - } +declare module '*.svg' { + import React from 'react'; + import { SvgProps } from 'react-native-svg'; + const content: React.FC; + export default content; +} diff --git a/client/types/file.ts b/client/types/file.ts index 4240241..88d7b8e 100644 --- a/client/types/file.ts +++ b/client/types/file.ts @@ -6,4 +6,4 @@ export interface File { upload_date: string; file_size: number; task_id: number; -} \ No newline at end of file +} diff --git a/cz.yaml b/cz.yaml new file mode 100644 index 0000000..b823e32 --- /dev/null +++ b/cz.yaml @@ -0,0 +1,8 @@ +--- +commitizen: + major_version_zero: true + name: cz_conventional_commits + tag_format: $version + update_changelog_on_bump: true + version: 0.0.1 + version_scheme: semver