Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
bagashiz committed Oct 2, 2023
0 parents commit daa25f9
Show file tree
Hide file tree
Showing 13 changed files with 394 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .air.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
root = "."
testdata_dir = "testdata"
tmp_dir = "tmp"

[build]
args_bin = []
bin = "./tmp/main"
cmd = "go build -o ./tmp/main ./cmd/app/main.go"
delay = 1000
exclude_dir = ["assets", "tmp", "vendor", "testdata"]
exclude_file = []
exclude_regex = ["_test.go"]
exclude_unchanged = false
follow_symlink = false
full_bin = ""
include_dir = ["cmd", "internal", "pkg", "docs"]
include_ext = ["go", "tpl", "tmpl", "html"]
include_file = [".env"]
kill_delay = "0s"
log = "build-errors.log"
poll = false
poll_interval = 0
rerun = false
rerun_delay = 500
send_interrupt = false
stop_on_error = true

[color]
app = ""
build = "yellow"
main = "magenta"
runner = "green"
watcher = "cyan"

[log]
main_only = false
time = false

[misc]
clean_on_exit = false

[screen]
clear_on_rebuild = false
keep_scroll = true
36 changes: 36 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# exclude any development-specific files
.vscode/
.idea/

# exclude any dependency directories
node_modules/
vendor/

# exclude build artifacts
build/
dist/
bin/
tmp/

# exclude any version control files
.git/

# exclude CI files
.github/
.gitlab-ci.yml

# exclude Docker files
Dockerfile*
docker-compose*.yml

# exclude any development-specific files
.*ignore
*.env
*.log
*.md
*.out
*.toml
*.test
**/*_test.go
*.yml
Makefile
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
APP_NAME=gommerce
APP_ENV=development
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "gomod" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
assignees:
- "bagashiz"
commit-message:
prefix: "chore(deps): "
48 changes: 48 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Continuous Integration

on:
push:
branches: ["main", "stable"]
pull_request:
branches: ["main", "stable"]

jobs:
lint:
name: Lint Code
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.21"
cache: false

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: "v1.53"
config: .golangci.yml

test:
name: Run Tests
runs-on: ubuntu-latest
needs: lint

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.21"

- name: Build
run: go build -v ./...

# - name: Test
# run: go run github.com/onsi/ginkgo/v2/ginkgo -v -r --randomize-all --randomize-suites --fail-on-pending --keep-going --cover --race --trace
42 changes: 42 additions & 0 deletions .github/workflows/publish-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Create and publish a Docker image

on:
push:
branches: ["stable"]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@v2.2.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4.6.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v4.1.1
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# exclude any development-specific files
.vscode/
.idea/

# exclude any dependency directories
node_modules/
vendor/

# exclude build artifacts
bin/
tmp/

# exclude any development-specific files
*.env
*.log
*.out
*.test
9 changes: 9 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
run:
timeout: "1m"
issue-exit-code: 1
tests: true
skip-dirs-use-default: true
skip-dirs:
- "opt"
allow-parallel-runners: false
go: "1.21"
62 changes: 62 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Contributing to Gommerce

First and foremost, thank you for your interest in contributing to Gommerce project! We appreciate your time and effort in helping us improve the project. To ensure a smooth and collaborative development process, please read the following guidelines before contributing to the project.

## Setting up the development environment

Before you start contributing to the project, you will need to set up your development environment. To get started, you should have the following software installed:

- [Go](https://golang.org/) 1.21 or higher
- [Task](https://taskfile.dev/)
- [Docker](https://www.docker.com/) or [Podman](https://podman.io/)
- [Docker Compose](https://docs.docker.com/compose/) or [Podman Compose](https://github.com/containers/podman-compose)

You should also have [Git](https://git-scm.com/) installed to clone the repository and submit merge requests.

To get started with the project, you can follow these steps:

1. Fork this repository.
2. Clone your forked repository to your local machine.
3. Install the project dependencies: `task install`
4. Create a copy of the `.env.example` file and rename it to `.env`. Update configuration values as needed.
5. Start the development server: `task dev`

## Submitting bug reports

If you encounter any issues with the project, please submit a bug report. To do so, please follow these guidelines:

1. Check the existing issues to see if your bug has already been reported.
2. If your bug has not been reported, create a new issue with a descriptive title and detailed steps to reproduce the bug.
3. Include any relevant error messages or screenshots.
4. Assign the `bug` label to the issue.

## Making feature requests

If you have an idea for a new feature, you can submit a feature request. To do so, please follow these guidelines:

1. Check the existing issues and merge requests to see if your feature request has already been submitted.
2. If your feature request has not been submitted, create a new issue with a descriptive title and detailed description of the feature.
3. Assign the `enhancement` label to the issue.

## Submitting code changes

If you would like to submit a code change, please follow these guidelines:

1. Create a new branch for your changes: `git checkout -b {feat,fix,refactor,docs,ci,chore,test}/my-new-branch-name`
2. Make your changes and once you are satisfied with your changes, commit them with a descriptive message using the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0) format.
3. Push your changes to your fork: `git push origin {feat,fix,refactor,docs,ci,chore,test}/my-new-branch-name`
4. Create a merge request against the `main` branch of the original repository.
5. Assign the appropriate labels to the merge request.

## Code standards

When submitting code changes, please adhere to the following standards:

1. **Formatting and linting**: Format your code using `gofmt` and lint your code using `golangci-lint`. Make sure your code passes all linting checks before submitting your changes. If you are on VS Code, you can install the [Go](https://marketplace.visualstudio.com/items?itemName=golang.Go) extension then use `golangci-lint` as a linter.
2. **Packages and imports**: Use goimports to organize imports and remove unused imports.
3. **Naming conventions**: Follow the Go naming conventions for variables, functions, and types. Use descriptive and meaningful names for variables, functions, and types. Avoid using abbreviations or acronyms unless they are well-known and widely used. Refer to the [Go Naming Slides](https://go.dev/talks/2014/names.slide) for more information.
4. **Comments**: Include comments to explain complex logic or provide clarity where needed. Use complete sentences and follow the Go commenting style (e.g., `//` for single-line comments and `/** ... */` for multi-line comments).

## Conclusion

Thank you for your interest in contributing to Gommerce project. We appreciate your time and effort in helping us improve the project. We look forward to your contributions and hope to see you in the community soon!
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Bagas Hizbullah

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Gommerce

## **⚠️WIP⚠️**

## Description

RESTful API for a simple e-commerce web service written in Go programming language. This is a final project for [Project-Based Internship at Evermos](https://www.rakamin.com/virtual-internship-experience/back-end-developer-evermos).

It uses [Echo](https://echo.labstack.com) as the web framework, [GORM](https://gorm.io) as the ORM library, and [MySQL](https://www.mysql.com) as the database.

## Getting Started

1. Ensure you have [Go](https://go.dev/dl/) 1.21 or higher and [Task](https://taskfile.dev/installation/) installed on your machine:

```bash
go version && task --version
```

2. Install all required tools for the project:

```bash
task install
```

3. Create a copy of the `.env.example` file and rename it to `.env`:

```bash
cp .env.example .env
```

Update configuration values as needed.

## Documentation

For database schema documentation, see here, powered by [dbdocs.io](https://dbdocs.io).

API documentation on progress.

## Contributing

Developers interested in contributing to Gommerce project can refer to the [CONTRIBUTING](CONTRIBUTING.md) file for detailed guidelines and instructions on how to contribute.

## License

Gommerce project is licensed under the [MIT License](LICENSE), providing an open and permissive licensing approach for further development and usage.

## Learning References

- [The Clean Architecture](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html) by Uncle Bob
Loading

0 comments on commit daa25f9

Please sign in to comment.