Skip to content

Commit

Permalink
setting workflows for publish and dal on matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
akrck02 committed May 24, 2024
1 parent db72170 commit 737cc75
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 28 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/go-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@
name: testing

on:
[push,pull_request]
push:
branches-ignore:
- main
pull_request:
branches-ignore:
- main

jobs:

test:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [ '1.19', '1.20', '1.21', '1.22.x' ]
steps:

# Get values for cache paths to be used in later steps
Expand Down Expand Up @@ -37,7 +45,7 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: 1.21.8
go-version: ${{ matrix.go-version }}
cache-dependency-path: api/go.sum

# In this step, this action saves a list of existing images,
Expand Down
22 changes: 2 additions & 20 deletions .github/workflows/publish_version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,36 +34,18 @@ jobs:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}

# Read version from file
- name: Read version
id: version
run: echo ::set-output name=version::$(cat version.config)

# Set up Go
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.21.8

# In this step, this action saves a list of existing images,
# the cache is created without them in the post run.
# It also restores the cache if it exists.
- uses: satackey/[email protected]
# Ignore the failure of a step and avoid terminating the job.
continue-on-error: true

- name: Set database running
uses: supercharge/[email protected]
with:
mongodb-username: admin
mongodb-password: p4ssw0rd
mongodb-db: valhalla-test
mongodb-port: 27017

- name: Create env file
run: echo "IP=127.0.0.1 \n PORT=3333 \n SECRET=secret \n GIN_MODE=release \n IP_MONGODB=172.0.0.1" > .env

- name: Run tests
run: go test -v ./...

- name: Create tag
uses: actions/github-script@v5
with:
Expand Down
67 changes: 67 additions & 0 deletions .github/workflows/publish_version_dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: publish-version-dev
on:
push:
branches-ignore:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

# Get values for cache paths to be used in later steps
- id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
# Cache go build cache, used to speedup go test
- name: Go Build Cache
uses: actions/cache@v2
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}

# Cache go mod cache, used to speedup builds
- name: Go Mod Cache
uses: actions/cache@v2
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}

# Read version from file
- name: Read version
id: version
run: echo ::set-output name=version::$(cat version.config)

# Read date in format YYYYMMDDHHMMSS
- name: Read date
id: date
run: echo ::set-output name=date::$(date +"%Y%m%d%H%M%S")

# Read branch name
- name: Read branch name
id: branch
run: echo ::set-output name=branch::${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}

# Set up Go
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.21.8

# Create tag with version, date and branch
- name: Create tag
uses: actions/github-script@v5
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{ steps.version.outputs.version }}-${{ steps.date.outputs.date }}-${{ steps.branch.outputs.branch }}',
sha: context.sha
})
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ go 1.21.8

require (
github.com/akrck02/valhalla-api-common v0.0.1
github.com/akrck02/valhalla-core-sdk v0.0.7
github.com/akrck02/valhalla-core-sdk v0.0.9-dev
github.com/golang-jwt/jwt/v5 v5.2.1
github.com/joho/godotenv v1.5.1
go.mongodb.org/mongo-driver v1.14.0
)
Expand All @@ -19,7 +20,6 @@ require (
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.14.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
github.com/golang/snappy v0.0.1 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.13.6 // indirect
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
github.com/akrck02/valhalla-api-common v0.0.1 h1:NwSTgj9AhHh5vA1faKi+k7GlGGLh+AwnzBGr4EiaPI8=
github.com/akrck02/valhalla-api-common v0.0.1/go.mod h1:nT+iqwWNm/Q1xG7/aORgKtzRT6rMthaiOYUQf7hLMew=
github.com/akrck02/valhalla-core-sdk v0.0.7 h1:6poICbaI0AtcUnCj51JmhiNrE12cvDpvq7vC2ROxRSQ=
github.com/akrck02/valhalla-core-sdk v0.0.7/go.mod h1:x3hf46f4+SfyE6SL4V1KX2Jvf5ERH/9FVrMa1EwM070=
github.com/akrck02/valhalla-core-sdk v0.0.9-dev h1:Doz/EAjDs/Xut6+WBNrhEx9qbLRy+nSd3JRvMHalF7M=
github.com/akrck02/valhalla-core-sdk v0.0.9-dev/go.mod h1:x3hf46f4+SfyE6SL4V1KX2Jvf5ERH/9FVrMa1EwM070=
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s=
github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U=
Expand All @@ -27,8 +27,6 @@ github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg
github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk=
github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
Expand Down

0 comments on commit 737cc75

Please sign in to comment.