Skip to content

Commit

Permalink
Merge branch 'main' into add-tailwind-themes
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusgomes28 authored Mar 16, 2024
2 parents 2958991 + 79e6602 commit 0b194b5
Show file tree
Hide file tree
Showing 41 changed files with 1,589 additions and 309 deletions.
2 changes: 1 addition & 1 deletion .air.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ tmp_dir = "tmp"
cmd = "make build"
args_bin = []
bin = "./tmp/urchin"
full_bin = "URCHIN_DATABASE_ADDRESS=localhost URCHIN_DATABASE_PORT=3306 URCHIN_DATABASE_USER=root URCHIN_DATABASE_PASSWORD=root URCHIN_DATABASE_NAME=gocms ./tmp/urchin"
full_bin = "./tmp/urchin --config urchin_config.toml"
delay = 1000
exclude_dir = ["assets", "tmp", "vendor", "testdata"]
exclude_file = []
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/actions/golangci-lint/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: golangci-lint step
description: golangci-lint step
inputs:
linters:
description: Linter to run
required: true
runs:
using: composite
steps:
- name: Generating templ files
run: |
templ generate
shell: bash

- name: prepping lint commands
id: set-command
run: |
export LINTERS="${{ inputs.linters }}"
export LINTER_CMD="golangci-lint run --disable-all -E ${LINTERS//;/ -E }"
echo "linter_cmd=${LINTER_CMD}" >> $GITHUB_OUTPUT
shell: bash

- name: running the linter command
run: eval ${{ steps.set-command.outputs.linter_cmd }}
shell: bash
30 changes: 30 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build

on: [workflow_call]

env:
CARGO_TERM_COLOR: always

jobs:
build:
name: Build ⚒️

runs-on: ubuntu-latest
container:
image: mattgomes28/urchin-golang:0.2
options: --user 1001

steps:
- uses: actions/checkout@v3
name: Checking Out Repo 👀
- name: Golang Build 🐹
run: make build
- name: Package 📦
run: |
mkdir urchin-ubuntu-build
cp tmp/urchin urchin-ubuntu-build/
cp tmp/urchin-admin urchin-ubuntu-build/
- uses: actions/upload-artifact@v3
with:
name: urchin-ubuntu-build
path: urchin-ubuntu-build
20 changes: 20 additions & 0 deletions .github/workflows/failfast.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Fail Fast

on: [workflow_call]

jobs:
linters:
name: Linters 🧑‍🔬

runs-on: ubuntu-latest
container:
image: mattgomes28/urchin-golang:0.2
options: --user 1001

steps:
- uses: actions/checkout@v3

- uses: ./.github/workflows/actions/golangci-lint
name: Running Linters 🧪
with:
linters: errcheck;staticcheck;unused;gosimple;gofmt
24 changes: 24 additions & 0 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Urchin CI ⚗️

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

jobs:
failfast:
uses: ./.github/workflows/failfast.yml

build:
uses: ./.github/workflows/build.yml
needs: failfast

tests:
uses: ./.github/workflows/test.yml
needs: build

# release:
# uses: ./.github/workflows/release.yml
# needs: tests
# if: github.ref == 'refs/heads/main'
27 changes: 27 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Tests

on: [workflow_call]

jobs:
linters:
name: Tests 🧪

runs-on: ubuntu-latest
container:
image: mattgomes28/urchin-golang:0.2
options: --user 1001

steps:
- uses: actions/checkout@v3

- name: Generating templ files
run: |
templ generate
shell: bash

- name: Running Go Tests 🧪
run: |
go test -coverprofile=coverage.out -covermode=atomic ./... -v
- name: Upload coverage to Codecov 📓
uses: codecov/codecov-action@v3
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.vscode
**/__debug*
**/*_templ.go
tmp/
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ build:
$(TAILWIND) -i ./static/style.css -o ./static/output.css -m
$(GOCMD) build -v -o $(BUILD_DIR)/$(BINARY_NAME) $(URCHIN_DIR)
$(GOCMD) build -v -o $(BUILD_DIR)/$(ADMIN_BINARY_NAME) $(URCHIN_ADMIN_DIR)
GIN_MODE=release $(GOCMD) build -ldflags "-s" -v -o $(BUILD_DIR)/$(BINARY_NAME) $(URCHIN_DIR)
GIN_MODE=release $(GOCMD) build -ldflags "-s" -v -o $(BUILD_DIR)/$(ADMIN_BINARY_NAME) $(URCHIN_ADMIN_DIR)

test:
$(GOCMD) test -v ./...
Expand All @@ -25,4 +27,7 @@ clean:
$(GOCMD) clean
rm -rf $(BUILD_DIR)

install-tools:
go install github.com/a-h/templ/cmd/[email protected]

.PHONY: all build test clean
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Urchin is a headless CMS (Content Management System) written in Golang, designed
create a website or blog, with any template you like, in only a few
commands.

![Really no head?](static/nohead.gif "So no head meme?")

## Features 🚀

- [x] **Headless Architecture:** Adding pages, posts, or forms should all
Expand All @@ -27,6 +29,22 @@ go get -u github.com/username/urchin

## Example - Running the App

First, ensure you have the neccesary libraries to run the application
```bash
make install-tools
```

Following that, make sure you run the Goose migrations for the database.
We recommend creating a database called `urchin` and running the following
command:

```bash
GOOSE_DRIVER="mysql" GOOSE_DBSTRING="root:root@/gocms" goose up
```

Replace the database connection string with the appropriate string
dependending on where your database is.

After you've replaced the default template files with your prefered
template, simply build and start the app with the following commands.

Expand All @@ -40,6 +58,20 @@ the configuration by providing the necessary environment variables.

For more information, see the [configuration settings](#configuration).

## Example - Running with Docker Compose

To run with `docker-compose`, use the following
command:

```bash
docker-compose up
```

This will start two containers: one containing the `urchin` app,
serving on port `8080`, and another one serving the `mariadb`
database internally. This will also run the migrations automatically
to setup the database!

## Architecture

Currently, the architecture of `urchin` is still in its early days.
Expand Down
Loading

0 comments on commit 0b194b5

Please sign in to comment.