-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from PromptPal/fix/ci-postgres
fix(ci): fix test in ci postgres
- Loading branch information
Showing
9 changed files
with
207 additions
and
114 deletions.
There are no files selected for viewing
This file contains 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 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,62 @@ | ||
name: Pull Requests check | ||
|
||
on: | ||
push: | ||
branches-ignore: [main, master] | ||
|
||
jobs: | ||
build: | ||
services: | ||
postgres: | ||
image: postgres:16 | ||
env: | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_DB: db_test | ||
ports: | ||
- 5432:5432 | ||
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | ||
|
||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Go 1.22 | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ^1.22 | ||
cache: true | ||
id: go | ||
- name: setup env | ||
run: | | ||
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV | ||
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH | ||
shell: bash | ||
- name: Generate | ||
run: | | ||
echo "GH_TAG=$(echo $GITHUB_REF | awk -F / '{print $3}')" >> $GITHUB_ENV | ||
go install github.com/vektra/mockery/v2@v2.42.0 | ||
go generate ./... | ||
rm ./routes/.env.testing | ||
echo "" > ./routes/.env.testing | ||
rm ./schema/.env.testing | ||
echo "" > ./schema/.env.testing | ||
- name: Test | ||
env: | ||
JWT_TOKEN_KEY: "4a9bca7269a3a29eb1026b3c0999b29b929ab59a" | ||
HASHID_SALT: "11111111" | ||
PUBLIC_DOMAIN: "localhost:7788" | ||
DB_TYPE: "postgres" | ||
DB_DSN: "host=localhost user=postgres password=postgres port=5432 dbname=db_test sslmode=disable" | ||
ADMIN_LIST: 0x4910c609fBC895434a0A5E3E46B1Eb4b64Cff2B8,0x7E63d899676756711d29DD989bb9F5a868C20e1D | ||
OPENAI_BASE_URL: "https://api.openai.com/v1" | ||
run: go test -race -coverprofile=coverage.txt -covermode=atomic ./... | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
- name: Build | ||
env: | ||
GOARCH: amd64 | ||
CGO_ENABLED: 1 | ||
GOOS: linux | ||
run: make release |
This file contains 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 |
---|---|---|
@@ -1,106 +1,98 @@ | ||
name: Build and Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
permissions: | ||
contents: write # to create release commit (google-github-actions/release-please-action) | ||
pull-requests: write # to create release PR (google-github-actions/release-please-action) | ||
|
||
jobs: | ||
build: | ||
services: | ||
postgres: | ||
image: postgres:16 | ||
env: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_DB: db_test | ||
ports: | ||
- 5432/tcp | ||
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | ||
|
||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: google-github-actions/release-please-action@v3 | ||
id: release | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
release-type: go | ||
- uses: actions/checkout@v4 | ||
- name: Set up Go 1.22 | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ^1.22 | ||
cache: true | ||
id: go | ||
- name: setup env | ||
run: | | ||
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV | ||
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH | ||
shell: bash | ||
- name: Generate | ||
run: | | ||
echo "GH_TAG=$(echo $GITHUB_REF | awk -F / '{print $3}')" >> $GITHUB_ENV | ||
go install github.com/vektra/mockery/v2@v2.42.0 | ||
go generate ./... | ||
awk -v db_type="postgres" -v db_dsn="\"host=postgres user=postgres password=postgres port=5432 dbname=db_test sslmode=disable\"" ' | ||
BEGIN { FS = OFS = "=" } | ||
$1 == "DB_TYPE" { $2 = db_type } | ||
$1 == "DB_DSN" { $2 = db_dsn } | ||
{ print } | ||
' ./routes/.env.testing > routes/.env.testing2 | ||
rm ./routes/.env.testing | ||
mv ./routes/.env.testing2 ./routes/.env.testing | ||
- name: Test | ||
run: go test -race -coverprofile=coverage.txt -covermode=atomic ./... | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
- name: Build | ||
if: ${{ steps.release.outputs.release_created }} | ||
env: | ||
GOARCH: amd64 | ||
CGO_ENABLED: 1 | ||
GOOS: linux | ||
run: | | ||
make release | ||
chmod +x up-pp-api | ||
- uses: dsaltares/fetch-gh-release-asset@master | ||
if: ${{ steps.release.outputs.release_created }} | ||
with: | ||
repo: "PromptPal/web" | ||
file: "dist.zip" | ||
target: "dist.zip" | ||
token: ${{ secrets.GH_PERSONAL_TOKEN }} | ||
- uses: montudor/action-zip@v1 | ||
if: ${{ steps.release.outputs.release_created }} | ||
with: | ||
args: unzip -qq dist.zip -d public | ||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
if: ${{ steps.release.outputs.release_created }} | ||
with: | ||
images: annatarhe/prompt-pal | ||
tags: ${{ steps.release.outputs.tag_name }} | ||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v3 | ||
if: ${{ steps.release.outputs.release_created }} | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v5 | ||
if: ${{ steps.release.outputs.release_created }} | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: ${{ github.event_name != 'pull_request' && steps.release.outputs.release_created }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
name: Build and Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
permissions: | ||
contents: write # to create release commit (google-github-actions/release-please-action) | ||
pull-requests: write # to create release PR (google-github-actions/release-please-action) | ||
|
||
jobs: | ||
build: | ||
services: | ||
postgres: | ||
image: postgres:16 | ||
env: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_DB: db_test | ||
ports: | ||
- 5432/tcp | ||
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | ||
|
||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: google-github-actions/release-please-action@v3 | ||
id: release | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
release-type: go | ||
- uses: actions/checkout@v4 | ||
- name: Set up Go 1.22 | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ^1.22 | ||
cache: true | ||
id: go | ||
- name: setup env | ||
run: | | ||
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV | ||
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH | ||
shell: bash | ||
- name: Generate | ||
run: | | ||
echo "GH_TAG=$(echo $GITHUB_REF | awk -F / '{print $3}')" >> $GITHUB_ENV | ||
go install github.com/vektra/mockery/v2@v2.42.0 | ||
go generate ./... | ||
- name: Test | ||
run: go test -race -coverprofile=coverage.txt -covermode=atomic ./... | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
- name: Build | ||
if: ${{ steps.release.outputs.release_created }} | ||
env: | ||
GOARCH: amd64 | ||
CGO_ENABLED: 1 | ||
GOOS: linux | ||
run: | | ||
make release | ||
chmod +x up-pp-api | ||
- uses: dsaltares/fetch-gh-release-asset@master | ||
if: ${{ steps.release.outputs.release_created }} | ||
with: | ||
repo: "PromptPal/web" | ||
file: "dist.zip" | ||
target: "dist.zip" | ||
token: ${{ secrets.GH_PERSONAL_TOKEN }} | ||
- uses: montudor/action-zip@v1 | ||
if: ${{ steps.release.outputs.release_created }} | ||
with: | ||
args: unzip -qq dist.zip -d public | ||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
if: ${{ steps.release.outputs.release_created }} | ||
with: | ||
images: annatarhe/prompt-pal | ||
tags: ${{ steps.release.outputs.tag_name }} | ||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v3 | ||
if: ${{ steps.release.outputs.release_created }} | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v5 | ||
if: ${{ steps.release.outputs.release_created }} | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: ${{ github.event_name != 'pull_request' && steps.release.outputs.release_created }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
This file contains 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 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 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
Oops, something went wrong.