feat(deploy): ✨ WIP setting fetch & test before build
This commit is contained in:
parent
07ec247b53
commit
283088648a
3 changed files with 68 additions and 13 deletions
|
|
@ -53,13 +53,6 @@ jobs:
|
|||
- run: git fetch --unshallow --quiet --tags --force
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
# - uses: docker/setup-buildx-action@v3
|
||||
# with:
|
||||
# buildkitd-flags: --debug
|
||||
# - name: Install containerd
|
||||
# run: |
|
||||
# sudo apt-get update
|
||||
# sudo apt-get install -y containerd
|
||||
- uses: docker/metadata-action@v5
|
||||
id: meta
|
||||
with:
|
||||
|
|
@ -75,14 +68,28 @@ jobs:
|
|||
registry: pakin-inspiron-15-3530.tail360bd.ts.net
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.ENV_GITEA_TOKEN }}
|
||||
- name: Get JQ
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install jq
|
||||
- name: Download settings
|
||||
run: |
|
||||
curl -H 'accept: application/json' -H 'authorization: Basic cGFraW46YWRtaW4xMjM=' "$(curl -X 'GET' \
|
||||
'https://pakin-inspiron-15-3530.tail360bd.ts.net/api/v1/repos/pakin/taobin_recipe_manager/releases/19/assets/73' \
|
||||
-H 'accept: application/json' \
|
||||
-H 'authorization: Basic cGFraW46YWRtaW4xMjM=' | jq -r '.browser_download_url')" | jq -r '.body.env' | base64 -d > ./server/app.env
|
||||
curl -H 'accept: application/json' -H 'authorization: Basic cGFraW46YWRtaW4xMjM=' "$(curl -X 'GET' \
|
||||
'https://pakin-inspiron-15-3530.tail360bd.ts.net/api/v1/repos/pakin/taobin_recipe_manager/releases/19/assets/73' \
|
||||
-H 'accept: application/json' \
|
||||
-H 'authorization: Basic cGFraW46YWRtaW4xMjM=' | jq -r '.browser_download_url')" | jq -r '.body.secret' | base64 -d > ./server/client_secret.json
|
||||
- name: Run Golang tests
|
||||
run: |
|
||||
cd server
|
||||
go test -v ./...
|
||||
- name: Build and push
|
||||
run: |
|
||||
pwd
|
||||
ls -al
|
||||
cd server
|
||||
pwd
|
||||
ls -al
|
||||
which docker
|
||||
echo "get ref name:${{ github.ref_name }}."
|
||||
/usr/bin/docker build -t pakin-inspiron-15-3530.tail360bd.ts.net/pakin/taobin_recipe_manager:latest -t pakin-inspiron-15-3530.tail360bd.ts.net/pakin/taobin_recipe_manager:${{ github.ref_name }} .
|
||||
/usr/bin/docker push pakin-inspiron-15-3530.tail360bd.ts.net/pakin/taobin_recipe_manager:latest
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ WORKDIR /app
|
|||
RUN apk update && apk add --no-cache sqlite curl
|
||||
|
||||
COPY --from=builder /app/recipe-manager .
|
||||
# COPY --from=builder /app/app.env .
|
||||
# COPY --from=builder /app/client_secret.json .
|
||||
COPY --from=builder /app/app.env .
|
||||
COPY --from=builder /app/client_secret.json .
|
||||
|
||||
# run the service on container startup.
|
||||
CMD ["/app/recipe-manager"]
|
||||
|
|
|
|||
48
server/main_test.go
Normal file
48
server/main_test.go
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"recipe-manager/config"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_loadConfig(t *testing.T) {
|
||||
type args struct {
|
||||
path string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want *config.ServerConfig
|
||||
wantErr bool
|
||||
}{
|
||||
// TODO: Add test cases.
|
||||
{
|
||||
name: "Test Config Local",
|
||||
args: args{
|
||||
".",
|
||||
},
|
||||
want: &config.ServerConfig{
|
||||
ServerPort: 8080,
|
||||
ServerDomain: "http://localhost:8080",
|
||||
AllowedOrigins: "http://localhost:4200,http://localhost:8080,http://localhost:3001",
|
||||
ClientRedirectURL: "http://localhost:4200/callback",
|
||||
APIKey: "AIzaSyDBdJMFN210IcJVmEGJ4AaPQm0FN50iH0s",
|
||||
Debug: true,
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got, err := loadConfig(tt.args.path)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("loadConfig() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
if !reflect.DeepEqual(got, tt.want) {
|
||||
t.Errorf("loadConfig() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue