Skip to content

Commit

Permalink
chore(cicd): updating the cicd for installing dependencies (#65)
Browse files Browse the repository at this point in the history
* updating the cicd for installing dependencies

* debug

* debug

* debug

* debug

* debug

* debug

* debug

* remove debug
  • Loading branch information
Jacobbrewer1 authored Nov 7, 2024
1 parent 49e095a commit 7100a85
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/ci-code-approval.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,16 @@ jobs:
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: git config --global url."https://x:${GITHUB_API_TOKEN}@github.com".insteadOf "https://github.com"

- name: "Install goschema"
run: |
wget https://github.com/jacobbrewer1/goschema/releases/download/v0.0.1/goschema
chmod +x goschema
mv goschema /usr/local/bin
- name: "Install dependencies"
run: make deps

- name: "Run Code Generation"
run: make codegen
env:
GS_SILENT: true

- name: "fmt"
run: go fmt ./...

- name: "Check for changes"
- name: "Fail if code generation changes files"
run: git diff --exit-code
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ pr-approval:
go build ./...
go vet ./...
go test ./...
codegen: deps
codegen:
@echo "Generating code"
go generate ./...
deps:
sudo apt-get install dos2unix
dos2unix ./pkg/models/generate.sh
chmod +x ./pkg/models/generate.sh
go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@latest
go install github.com/charmbracelet/gum@latest
go install golang.org/x/tools/cmd/goimports@latest
go install github.com/jacobbrewer1/goschema@latest
models:
chmod +x ./pkg/models/generate.sh
go generate ./pkg/models
Expand Down
14 changes: 14 additions & 0 deletions pkg/models/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ fi
all=false
clean=false
forced=false
silent=false

# Get the flags passed to the script and set the variables accordingly
while getopts "acf" flag; do
Expand All @@ -38,6 +39,11 @@ while getopts "acf" flag; do
esac
done

# If the silent environment variable is set, set the silent flag to true
if [ "$GS_SILENT" = true ]; then
silent=true
fi

# If the -c flag is passed, remove all generated models
if [ "$clean" = true ]; then
if [ "$forced" = false ]; then
Expand All @@ -50,6 +56,14 @@ fi

# If the -a flag is passed, generate all models
if [ "$all" = true ]; then
if [ "$silent" = true ]; then
echo "Generating all models"
goschema generate --out=./ --sql=./schemas/*.sql --extension=xo
go fmt ./*.xo.go
goimports -w ./*.xo.go
exit 0
fi

gum spin --spinner dot --title "Generating all models" -- goschema generate --out=./ --sql=./schemas/*.sql --extension=xo
go fmt ./*.xo.go
goimports -w ./*.xo.go
Expand Down
4 changes: 2 additions & 2 deletions pkg/models/schemas/season.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
create table season
(
id int not null auto_increment,
year int not null,
id int not null auto_increment,
year int not null,
primary key (id)
);

0 comments on commit 7100a85

Please sign in to comment.