Skip to content

Commit

Permalink
ci: update workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
kynrai committed Jul 7, 2024
1 parent 7990d65 commit c5f9e3f
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 79 deletions.
30 changes: 25 additions & 5 deletions template/.github/workflows/golang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,41 @@ name: Golang CI
on: workflow_dispatch

jobs:
cache_checkout:
checkout:
name: Checkout
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/upload-artifact@v3
- uses: actions/checkout@v4
name: Checkout project
- uses: actions/setup-node@v4
name: Install Node.js
with:
node-version: "lts/*"
check-latest: true
- run: npm i -g tailwindcss@latest
name: Install Tailwind CSS
- run: npx tailwindcss -i ./internal/ui/styles.css -o ./internal/server/assets/css/styles.css
name: Generate Tailwind CSS
- uses: actions/setup-go@v5
name: Install Golang
with:
go-version-file: "go.mod"
- run: go install github.com/a-h/templ/cmd/templ@latest
name: Install Templ
- run: templ generate
name: Generate templ files
- uses: actions/upload-artifact@v4
name: Upload artifact
with:
name: checkout-${{ github.run_id }}
path: ${{ github.workspace }}/**/*

lint:
needs: cache_checkout
needs: checkout
name: Lint
uses: "./.github/workflows/lint.yml"

test:
needs: cache_checkout
needs: checkout
name: Test
uses: ./.github/workflows/test.yml
14 changes: 5 additions & 9 deletions template/.github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@ on: workflow_call

jobs:
lint:
name: Lint
name: golangci-lint
runs-on: ubuntu-latest
steps:
- name: Get Cached Checkout
uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
name: Get Cached Checkout
with:
name: checkout-${{ github.run_id }}
- uses: actions/setup-go@v5
name: Install Golang
with:
go-version-file: "go.mod"
- name: GolangCI-Lint
uses: golangci/golangci-lint-action@v6
- uses: golangci/golangci-lint-action@v6
name: Run golangci-lint
with:
version: v1.59
10 changes: 5 additions & 5 deletions template/.github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
name: lint
name: Test

on: workflow_call

jobs:
test:
name: Test
name: Golang unit tests
runs-on: ubuntu-latest
steps:
- name: Get Cached Checkout
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: checkout-${{ github.run_id }}
- uses: actions/setup-go@v5
name: Install Golang
with:
go-version-file: "go.mod"
- name: Test
run: make test
- run: make test
name: Run unit tests
3 changes: 3 additions & 0 deletions template/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
issues:
exclude-files:
- ".*_templ\\.go$"
19 changes: 0 additions & 19 deletions template/internal/ui/components/modal.templ

This file was deleted.

35 changes: 0 additions & 35 deletions template/internal/ui/components/modal_templ.go

This file was deleted.

23 changes: 20 additions & 3 deletions template/internal/ui/index.templ
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package ui

import "module/placeholder/internal/ui/components"

templ Index() {
<!DOCTYPE html>
<html lang="en">
Expand All @@ -14,8 +12,27 @@ templ Index() {
<body>
<main class="flex">
<h1>10.10.0</h1>
@components.Modal()
@Modal()
</main>
</body>
</html>
}

// Example components, can delete or adapt
templ Modal() {
<dialog id="modal">
<button autofocus>
<script>
me().on("click", ev => { me("#modal").close() })
</script>
Close
</button>
<p>Modal content</p>
</dialog>
<button>
<script>
me().on("click", ev => { me("#modal").showModal() })
</script>
Show the modal
</button>
}
31 changes: 28 additions & 3 deletions template/internal/ui/index_templ.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c5f9e3f

Please sign in to comment.