diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..1d166a5 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,29 @@ +name: Build and push + +on: + push: + branches: + - main + +jobs: + build: + permissions: + packages: write + runs-on: 'ubuntu-latest' + steps: + - uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ github.token }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + push: true + tags: ghcr.io/${{ github.repository }}:latest diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..cf2e5a0 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,37 @@ +# The "display name", shown in the GitHub UI +name: Build and test + +# Trigger, run on push on any branch +on: + pull_request: + +jobs: + test: # The 'build' job + name: "Build application" + runs-on: 'ubuntu-latest' + steps: + # Checkout code + - uses: actions/checkout@v4 + + # Install go 1.21 + - name: Setup go + uses: actions/setup-go@v4 + with: # Specify input variables to the action + go-version: '1.21.x' + + # Shell script to print the version + - run: go version + + - name: Build + run: go build -v ./... + + - name: Test + run: go test ./... + lint: + name: "Lint code" + runs-on: 'ubuntu-latest' + steps: + - name: Verify formatting + run: | + no_unformatted_files="$(gofmt -l $(git ls-files '*.go') | wc -l)" + exit "$no_unformatted_files" \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/internal/greeting/greet.go b/internal/greeting/greet.go index 68dc637..6ea78f4 100644 --- a/internal/greeting/greet.go +++ b/internal/greeting/greet.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" ) - +// Nice feature comment func Greet(names []string) (string, error) { if len(names) == 0 { return "", errors.New("at least one name must be specified")