Skip to content

Commit

Permalink
Merge pull request #108 from wednesday-solutions/fix/pre-commit
Browse files Browse the repository at this point in the history
fix(pre-commit): Fix support for pre-commit
  • Loading branch information
ijas-ws authored Aug 20, 2023
2 parents 69a3960 + c3b42c1 commit 2208667
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 56 deletions.
23 changes: 17 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: "3.x"

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

- name: Install pre-commit dependencies
run: |
Expand All @@ -25,7 +28,9 @@ jobs:
go install golang.org/x/lint/golint@latest
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
- uses: pre-commit/[email protected]
- name: Run pre-commit
uses: pre-commit/[email protected]

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

Expand All @@ -36,8 +41,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

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

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
go-version: 1.19
- uses: golangci/[email protected]
version: 1.54
12 changes: 6 additions & 6 deletions .github/workflows/product-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,37 +32,37 @@ jobs:
declare -A categoryTitle=( [fix]="<h5>Bug Fixes</h5>" [chore]="<h5>Changes to build process or aux tools</h5>" [revert]="<h5>Revert Commits</h5>" [build]="<h5>Build</h5>" [docs]="<h5>Documentation</h5>" [feat]="<h5>New Features</h5>" [perf]="<h5>Performace Enhancements</h5>" [refactor]="<h5>Refactored</h5>" [style]="<h5>Changed Style</h5>" [temp]="<h5>Temporary Commit</h5>" [test]="<h5>Added Tests</h5>" [ci]="<h5>Changes to CI config</h5>" [others]="<h5>Others</h5>")
msg="#${{ steps.getMergedPR.outputs.number }} ${{ steps.getMergedPR.outputs.title }}"
for i in $(git log --format=%h $(git merge-base HEAD^1 HEAD^2)..HEAD^2)
do
do
IFS=":" read -r type cmmsg <<< $(git log --format=%B -n 1 $i)
type="${type}" | xargs
text_msg="&nbsp;&nbsp;&nbsp;&nbsp;&#8226; $i - ${cmmsg}<br/>"
flag=1
for i in "${!category[@]}"
do
if [ "${type}" == "$i" ]
then
then
category[$i]+="${text_msg}"
flag=0
break
fi
done
if [ $flag -eq 1 ]
then
then
category[others]+="${text_msg}"
fi
done
for i in "${!category[@]}"
do
if [ ! -z "${category[$i]}" ] && [ "others" != "$i" ]
then
then
msg+="${categoryTitle[$i]}${category[$i]}"
fi
done
if [ ! -z "${category[others]}" ]
then
then
msg+="${categoryTitle[others]}${category[others]}"
fi
echo "New Release Note: $msg"
echo "New Release Note: $msg"
echo "COMMIT_MESSAGE=${msg}" >> $GITHUB_ENV
- name: Bump Version
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.DS_Store
coverage.out
coverage.out
17 changes: 16 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
fail_fast: true
repos:
- repo: https://github.com/tekwizely/pre-commit-golang
rev: v1.0.0-beta.5
rev: v1.0.0-rc.1
hooks:
- id: go-fmt
- id: go-vet-mod
Expand All @@ -10,3 +10,18 @@ repos:
- id: go-build-repo-mod
- id: go-mod-tidy
- id: go-mod-tidy-repo
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/dnephin/pre-commit-golang
rev: v0.5.1
hooks:
- id: go-fmt
- id: go-imports
- id: no-go-testing
- id: golangci-lint
- id: go-unit-tests
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ This tool will have support for production applications using the following tech
AWS Access Key ID: MYACCESSKEYID
AWS Secret Access Key: MYSECRETKEY
Default region name [us-west-2]: MYAWSREGION
Default output format [None]:
Default output format [None]:
```


Expand Down Expand Up @@ -151,7 +151,7 @@ You can see `picky`'s home page if you initialized atleast one stack. You can ch

<img width="551" alt="Picky Home Preview Image" src="https://github.com/wednesday-solutions/service-picker/assets/114065489/322fc49b-43b3-4d0e-9753-6db6d3dd96a5">

***Tips:***
***Tips:***
- If you want to go back from the prompt, click `Ctrl + D`
- If you want to exit from the prompt, click `Ctrl + C`

Expand Down
66 changes: 33 additions & 33 deletions pickyhelpers/convert_queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ func ConvertQueries(stack, dirName string) error {
create type grant_type_enum as ENUM('CLIENT_CREDENTIALS');
create table oauth_clients (
id INT NOT NULL PRIMARY KEY DEFAULT NEXTVAL ('oauth_clients_seq'),
client_id VARCHAR(320) NOT NULL,
client_secret VARCHAR(36) NOT NULL,
grant_type grant_type_enum,
id INT NOT NULL PRIMARY KEY DEFAULT NEXTVAL ('oauth_clients_seq'),
client_id VARCHAR(320) NOT NULL,
client_secret VARCHAR(36) NOT NULL,
grant_type grant_type_enum,
created_at TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at TIMESTAMP(0) NULL,
CONSTRAINT oauth_clients_client_id UNIQUE (client_id)
Expand All @@ -35,16 +35,16 @@ CREATE INDEX oauth_clients_client_secret_idx ON oauth_clients(client_secret);`

users := `CREATE SEQUENCE users_seq;
CREATE TABLE users
(
id INT NOT NULL DEFAULT NEXTVAL ('users_seq') PRIMARY KEY,
oauth_client_id INT NOT NULL,
first_name VARCHAR (32) NOT NULL,
last_name VARCHAR(32) NOT NULL,
email VARCHAR(32) NOT NULL,
created_at TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP NOT NULL,
CONSTRAINT users_oauth_clients_id_fk FOREIGN KEY (oauth_client_id)
REFERENCES oauth_clients (id) ON UPDATE CASCADE
CREATE TABLE users
(
id INT NOT NULL DEFAULT NEXTVAL ('users_seq') PRIMARY KEY,
oauth_client_id INT NOT NULL,
first_name VARCHAR (32) NOT NULL,
last_name VARCHAR(32) NOT NULL,
email VARCHAR(32) NOT NULL,
created_at TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP NOT NULL,
CONSTRAINT users_oauth_clients_id_fk FOREIGN KEY (oauth_client_id)
REFERENCES oauth_clients (id) ON UPDATE CASCADE
);`

oauthAccessTokens := `create sequence oauth_access_tokens_seq;
Expand All @@ -67,31 +67,31 @@ END;
$function$;
create table oauth_access_tokens (
id INT NOT NULL PRIMARY KEY DEFAULT NEXTVAL ('oauth_access_tokens_seq'),
oauth_client_id INT NOT NULL,
access_token VARCHAR(64) NOT NULL,
expires_in INTEGER CHECK (expires_in > 0) NOT NULL,
expires_on TIMESTAMP(0) NOT NULL,
metadata JSON NOT NULL,
id INT NOT NULL PRIMARY KEY DEFAULT NEXTVAL ('oauth_access_tokens_seq'),
oauth_client_id INT NOT NULL,
access_token VARCHAR(64) NOT NULL,
expires_in INTEGER CHECK (expires_in > 0) NOT NULL,
expires_on TIMESTAMP(0) NOT NULL,
metadata JSON NOT NULL,
created_at TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at TIMESTAMP(0) NULL,
CONSTRAINT oauth_access_tokens_access_token_uindex UNIQUE (access_token),
updated_at TIMESTAMP(0) NULL,
CONSTRAINT oauth_access_tokens_access_token_uindex UNIQUE (access_token),
CONSTRAINT oauth_access_tokens_oauth_clients_id_fk FOREIGN KEY (oauth_client_id) REFERENCES oauth_clients (id) ON UPDATE CASCADE,
CONSTRAINT oauth_access_tokens_check_metadata CHECK(is_json_valid(metadata))
);`

oauthClientResources := `create sequence oauth_client_resources_seq;
create table oauth_client_resources (
id INT NOT NULL PRIMARY KEY DEFAULT NEXTVAL ('oauth_client_resources_seq'),
oauth_client_id INT NOT NULL,
resource_type VARCHAR(36) NOT NULL,
resource_id VARCHAR(36) NOT NULL,
id INT NOT NULL PRIMARY KEY DEFAULT NEXTVAL ('oauth_client_resources_seq'),
oauth_client_id INT NOT NULL,
resource_type VARCHAR(36) NOT NULL,
resource_id VARCHAR(36) NOT NULL,
created_at TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at TIMESTAMP(0) NULL,
updated_at TIMESTAMP(0) NULL,
CONSTRAINT oauth_client_resources_oauth_client_id_resource_uindex UNIQUE (
oauth_client_id, resource_type, resource_id
),
),
CONSTRAINT oauth_client_resources_oauth_clients_id_fk FOREIGN KEY (oauth_client_id) REFERENCES oauth_clients (id) ON UPDATE CASCADE
);
Expand All @@ -101,11 +101,11 @@ CREATE INDEX oauth_client_resources_resource_id ON oauth_client_resources(resour
oauthClientScopes := `create sequence oauth_client_scopes_seq;
create table oauth_client_scopes (
id INT NOT NULL DEFAULT NEXTVAL ('oauth_client_scopes_seq') PRIMARY KEY,
oauth_client_id INT NOT NULL,
scope VARCHAR (36) NOT NULL,
created_at TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at TIMESTAMP(0) NULL,
id INT NOT NULL DEFAULT NEXTVAL ('oauth_client_scopes_seq') PRIMARY KEY,
oauth_client_id INT NOT NULL,
scope VARCHAR (36) NOT NULL,
created_at TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at TIMESTAMP(0) NULL,
constraint oauth_client_scopes_uindex UNIQUE (oauth_client_id),
constraint oauth_client_scopes_oauth_clients_id_fk FOREIGN KEY (oauth_client_id) REFERENCES oauth_clients (id) ON UPDATE CASCADE
);`
Expand Down
6 changes: 3 additions & 3 deletions pickyhelpers/create_dockercompose.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ services:`
source = fmt.Sprintf(`%s
# Setup {{PostgreSQL}}
%s_db:
image: '{{dbVersion PostgreSQL}}'
image: '{{dbVersion PostgreSQL}}'
ports:
- %s:%d
restart: always # This will make sure that the container comes up post unexpected shutdowns
Expand Down Expand Up @@ -96,7 +96,7 @@ services:`
source = fmt.Sprintf(`%s
# Setup {{MySQL}}
%s_db:
image: '{{dbVersion MySQL}}'
image: '{{dbVersion MySQL}}'
ports:
- %s:%d
restart: always # This will make sure that the container comes up post unexpected shutdowns
Expand Down Expand Up @@ -146,7 +146,7 @@ services:`
command: ['redis-server']
{{/if}}
{{#each webDirectories}}
{{#each webDirectories}}
# Setup {{this}} web
{{this}}:
build:
Expand Down
2 changes: 1 addition & 1 deletion pickyhelpers/sources/create_cd_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
name: Docker build image and push
runs-on: ubuntu-latest
defaults:
run:
run:
working-directory: ./%s
strategy:
matrix:
Expand Down
6 changes: 3 additions & 3 deletions pickyhelpers/sources/create_infra_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ export function %s({ stack }) {
const taskDefinition = new ecs.TaskDefinition(
stack,
%s${clientName}-task-${environment}%s,
%s${clientName}-task-${environment}%s,
{
family: %s${clientName}-task-definition-${environment}%s,
compatibility: ecs.Compatibility.EC2_AND_FARGATE,
Expand Down Expand Up @@ -439,7 +439,7 @@ export function %s({ stack }) {
});
const container = taskDefinition.addContainer(
%s${clientName}-container-${environment}%s,
%s${clientName}-container-${environment}%s,
{
image,
cpu: 512,
Expand Down Expand Up @@ -637,7 +637,7 @@ function parseOutputs() {
fileContent = JSON.stringify(fileContent, null, 2);
fs.writeFileSync(outputFile, fileContent);
}
parseOutputs();
parseOutputs();
`
return source
}

0 comments on commit 2208667

Please sign in to comment.