-
Notifications
You must be signed in to change notification settings - Fork 18
feat(ci): implement ci pipeline #48
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a7b527c
feat(ci): create ci and lint config
Bolu1 3bed33a
fix(docker): make docker file simplier
Bolu1 1a1a18d
fix(docker): make docker file simplier
Bolu1 70c6ea6
fix(ci): reducing lint strictness, modify the ci
Bolu1 d4bea8d
fix(ci): fix migrations path
Bolu1 21e48e7
fix(ci): fix linting errors
Bolu1 0c772f8
fix(ci): update upload artifact version
Bolu1 ca2831a
fix(ci): update upload artifact version
Bolu1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| name: DefiFundr CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ '**' ] | ||
| pull_request: | ||
| branches: [ '**' ] | ||
|
|
||
| jobs: | ||
| lint: | ||
| name: Lint | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v3 | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v3 | ||
| with: | ||
| go-version: 1.19 | ||
| cache: true | ||
|
|
||
| - name: Install golangci-lint | ||
| run: | | ||
| curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.52.2 | ||
|
|
||
| - name: Lint code | ||
| run: | | ||
| export PATH=$PATH:$(go env GOPATH)/bin | ||
| golangci-lint run --timeout=5m | ||
|
|
||
| test: | ||
| name: Test | ||
| runs-on: ubuntu-latest | ||
| services: | ||
| postgres: | ||
| image: postgres:15 | ||
| env: | ||
| POSTGRES_PASSWORD: ${{ secrets.DB_PASSWORD || 'secret' }} | ||
| POSTGRES_USER: ${{ secrets.DB_USER || 'root' }} | ||
| POSTGRES_DB: ${{ secrets.DB_NAME || 'defi' }} | ||
| options: >- | ||
| --health-cmd pg_isready | ||
| --health-interval 10s | ||
| --health-timeout 5s | ||
| --health-retries 5 | ||
| ports: | ||
| - 5433:5432 | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v3 | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v3 | ||
| with: | ||
| go-version: 1.19 | ||
| cache: true | ||
|
|
||
| - name: "Create env file" | ||
| run: | | ||
| touch .env | ||
| echo "${{ secrets.ENV_FILE }}" > .env | ||
| cat .env | ||
|
|
||
| - name: Install golang-migrate | ||
| run: | | ||
| curl -L https://github.com/golang-migrate/migrate/releases/download/v4.15.2/migrate.linux-amd64.tar.gz | tar xvz | ||
| sudo mv migrate /usr/bin/migrate | ||
| which migrate | ||
|
|
||
| - name: Run database migrations | ||
| run: migrate -path db/migrations -database "postgresql://${{ secrets.DB_USER || 'root' }}:${{ secrets.DB_PASSWORD || 'secret' }}@localhost:5433/${{ secrets.DB_NAME || 'defi' }}?sslmode=disable" -verbose up | ||
|
|
||
| - name: Install dependencies | ||
| run: go mod download | ||
|
|
||
| - name: Run tests | ||
| run: go test -v -race -coverprofile=coverage.txt -covermode=atomic ./... | ||
| env: | ||
| DB_SOURCE: postgresql://${{ secrets.DB_USER || 'root' }}:${{ secrets.DB_PASSWORD || 'secret' }}@localhost:5433/${{ secrets.DB_NAME || 'defi' }}?sslmode=disable | ||
|
|
||
| - name: Upload coverage to Codecov | ||
| uses: codecov/codecov-action@v3 | ||
| with: | ||
| file: ./coverage.txt | ||
| fail_ci_if_error: false | ||
|
|
||
| build: | ||
| name: Build | ||
| runs-on: ubuntu-latest | ||
| needs: [lint, test] | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v3 | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v3 | ||
| with: | ||
| go-version: 1.19 | ||
| cache: true | ||
|
|
||
| - name: Build application | ||
| run: go build -v -o defifundr_backend ./cmd/api | ||
|
|
||
| - name: Upload artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: defifundr-backend | ||
| path: defifundr_backend | ||
| retention-days: 5 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| linters: | ||
| enable: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. reduce sensitivity of linter for now |
||
| - errcheck | ||
| - govet | ||
|
|
||
| issues: | ||
| exclude-rules: | ||
| - path: _test\.go | ||
| linters: | ||
| - errcheck | ||
|
|
||
| run: | ||
| timeout: 5m | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| package seeds |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check previous CI implementation. Use similar strategies, avoid exposing sensitive data in CI implementation