Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: code format #61

Merged
merged 10 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
200 changes: 200 additions & 0 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
name: PR-Check

on:
pull_request:
branches: [ "main" ]

defaults:
run:
shell: bash

env:
GO_VERSION: 1.23.4
PNAME: gateway

jobs:
format_check:
runs-on: ubuntu-latest
steps:
- name: Checkout current repository
uses: actions/checkout@v4
with:
path: ${{ env.PNAME }}

- name: Checkout framework repository
uses: actions/checkout@v4
with:
repository: infinilabs/framework
path: framework

- name: Checkout framework-vendor
uses: actions/checkout@v4
with:
ref: main
repository: infinilabs/framework-vendor
path: vendor

- name: Set up go toolchain
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
check-latest: false
cache: true

- name: Check go toolchain
run: go version

- name: Code format
shell: bash
run: |
echo Home path is $HOME
export WORKBASE=$HOME/go/src/infini.sh
export WORK=$WORKBASE/$PNAME

# for format workspace
mkdir -p $HOME/go/src/
ln -s $GITHUB_WORKSPACE $WORKBASE

# check work folder
ls -lrt $WORKBASE/
ls -alrt $WORK

# for code format
cd $WORK
echo Formating code at $PWD ...
make format

- name: Check for changes after format
id: check-changes
shell: bash
run: |
export WORKBASE=$HOME/go/src/infini.sh
export WORK=$WORKBASE/$PNAME

# for foramt check
cd $WORK
if [[ $(git status --porcelain | grep -c " M .*\.go$") -gt 0 ]]; then
echo "go format detected formatting changes"
echo "changes=true" >> $GITHUB_OUTPUT
else
echo "go format no changes found"
echo "changes=false" >> $GITHUB_OUTPUT
fi

- name: Fail workflow if changes after format
if: steps.check-changes.outputs.changes == 'true'
run: |
export WORKBASE=$HOME/go/src/infini.sh
export WORK=$WORKBASE/$PNAME

# for foramt check
cd $WORK && echo
git status --porcelain | grep " M .*\.go$"
echo "----------------------------------------------------------------------------------"
echo "IMPORTANT: Above files are not formatted, please run 'make format' to format them."
echo "----------------------------------------------------------------------------------"
exit 1

unit_test:
runs-on: ubuntu-latest
steps:
- name: Checkout current repository
uses: actions/checkout@v4
with:
path: ${{ env.PNAME }}

- name: Checkout framework repository
uses: actions/checkout@v4
with:
repository: infinilabs/framework
path: framework

- name: Checkout framework-vendor
uses: actions/checkout@v4
with:
ref: main
repository: infinilabs/framework-vendor
path: vendor

- name: Set up go toolchain
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
check-latest: false
cache: true

- name: Check go toolchain
run: go version

- name: Unit test
env:
GOFLAGS: -tags=ci
run: |
echo Home path is $HOME
export WORKBASE=$HOME/go/src/infini.sh
export WORK=$WORKBASE/$PNAME

# for test workspace
mkdir -p $HOME/go/src/
ln -s $GITHUB_WORKSPACE $WORKBASE

# check work folder
ls -lrt $WORKBASE/
ls -alrt $WORK

# for unit test
cd $WORK
echo Testing code at $PWD ...
make test

code_lint:
runs-on: ubuntu-latest
steps:
- name: Checkout current repository
uses: actions/checkout@v4
with:
path: ${{ env.PNAME }}

- name: Checkout framework repository
uses: actions/checkout@v4
with:
repository: infinilabs/framework
path: framework

- name: Checkout framework-vendor
uses: actions/checkout@v4
with:
ref: main
repository: infinilabs/framework-vendor
path: vendor

- name: Set up go toolchain
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
check-latest: false
cache: true

- name: Check go toolchain
run: go version

- name: Code lint
env:
GOFLAGS: -tags=ci
run: |
echo Home path is $HOME
export WORKBASE=$HOME/go/src/infini.sh
export WORK=$WORKBASE/$PNAME

# for lint workspace
mkdir -p $HOME/go/src/
ln -s $GITHUB_WORKSPACE $WORKBASE

# check work folder
ls -lrt $WORKBASE/
ls -alrt $WORK

# for code lint
cd $WORK
echo Linting code at $PWD ...
make lint
67 changes: 0 additions & 67 deletions .github/workflows/unit_test.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ vendor
trash
*.so
.public
/config/generated.go
config/generated.go
config/generat*.go
generated_*.go
*.swp
1 change: 1 addition & 0 deletions config/generated.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package config

const LastCommitLog = "N/A"

const BuildDate = "N/A"

const EOLDate = "N/A"
Expand Down
1 change: 0 additions & 1 deletion proxy/filters/security/ldap/ldap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func TestLDAPFunctions(t *testing.T) {
UserFilter: "(uid=%s)",
}


r := &fasthttp.Request{}
r.SetBasicAuth("galieleo", "password")

Expand Down
Loading