Skip to content
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

test #13

Open
wants to merge 90 commits into
base: Projeto_base
Choose a base branch
from
Open

test #13

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
f43d059
Update go.yml
Luc4592 May 7, 2023
731eea2
Test-1
Luc4592 May 7, 2023
dca126f
Teste-2
Luc4592 May 7, 2023
0cf74a3
Update go.yml
Luc4592 May 7, 2023
9d169be
Test-1
Luc4592 May 7, 2023
2364079
Update go.yml
Luc4592 May 7, 2023
0dad31b
Create Docker.yml
Luc4592 May 7, 2023
5410931
Update go.yml
Luc4592 May 7, 2023
e0ec229
Update Docker.yml
Luc4592 May 7, 2023
67ba516
Update Docker.yml
Luc4592 May 7, 2023
ea760aa
Update go.yml
Luc4592 May 7, 2023
e44f175
Update go.yml
Luc4592 May 7, 2023
e31eb5a
Update go.yml
Luc4592 May 7, 2023
a5a9970
Update go.yml
Luc4592 May 7, 2023
f445bdb
Update go.yml
Luc4592 May 7, 2023
703ee29
Update Docker.yml
Luc4592 May 7, 2023
1f4c884
Update go.yml
Luc4592 May 7, 2023
d4dfd18
Update Docker.yml
Luc4592 May 7, 2023
a63dc82
Update go.yml
Luc4592 May 7, 2023
2ae1789
Update Docker.yml
Luc4592 May 7, 2023
8d16efd
Update go.yml
Luc4592 May 7, 2023
278535e
Update go.yml
Luc4592 May 7, 2023
bbe8fcb
Update go.yml
Luc4592 May 7, 2023
8898fb7
Update Docker.yml
Luc4592 May 7, 2023
0fa1001
Update go.yml
Luc4592 May 7, 2023
f4467d9
Update go.yml
Luc4592 May 7, 2023
4f337f6
Update go.yml
Luc4592 May 7, 2023
a50afd3
Update go.yml
Luc4592 May 7, 2023
d0e3a0d
Update Docker.yml
Luc4592 May 7, 2023
6e1d9ad
Update go.yml
Luc4592 May 7, 2023
aa0bdde
Update go.yml
Luc4592 May 7, 2023
c4aa119
Update go.yml
Luc4592 May 7, 2023
41248a4
Update go.yml
Luc4592 May 7, 2023
b165fcb
Update go.yml
Luc4592 May 7, 2023
89049a0
Update go.yml
Luc4592 May 7, 2023
cc490c1
Update go.yml
Luc4592 May 7, 2023
9780f4d
Update go.yml
Luc4592 May 7, 2023
a55f8b7
Update go.yml
Luc4592 May 7, 2023
e124cd1
Update go.yml
Luc4592 May 7, 2023
03c5c30
Update go.yml
Luc4592 May 7, 2023
c075398
Update go.yml
Luc4592 May 7, 2023
c9282a3
Update go.yml
Luc4592 May 7, 2023
045bc6f
Update go.yml
Luc4592 May 7, 2023
528a392
Update go.yml
Luc4592 May 7, 2023
3550698
Update go.yml
Luc4592 May 7, 2023
876712e
Update go.yml
Luc4592 May 7, 2023
00b59ad
Update go.yml
Luc4592 May 7, 2023
f87fd0e
Update go.yml
Luc4592 May 7, 2023
227a8b1
Update go.yml
Luc4592 May 7, 2023
b50d8fd
Update go.yml
Luc4592 May 7, 2023
9f1991b
Update go.yml
Luc4592 May 7, 2023
05cc351
Update go.yml
Luc4592 May 7, 2023
7d49f7d
Update go.yml
Luc4592 May 7, 2023
631c0dc
Update go.yml
Luc4592 May 7, 2023
aa43246
Update go.yml
Luc4592 May 7, 2023
5f33ee0
Update go.yml
Luc4592 May 7, 2023
62a11a3
Update Docker.yml
Luc4592 May 7, 2023
793f930
Update go.yml
Luc4592 May 7, 2023
796d358
Update Docker.yml
Luc4592 May 7, 2023
3119351
Update go.yml
Luc4592 May 7, 2023
b616dc7
Update go.yml
Luc4592 May 7, 2023
b4eeb64
Update Docker.yml
Luc4592 May 7, 2023
4d6a32a
Create Dockerfile
Luc4592 May 7, 2023
f6fb155
Update go.yml
Luc4592 May 7, 2023
180be7f
Update db.go
Luc4592 May 7, 2023
45b96a0
Update go.yml
Luc4592 May 7, 2023
21158cf
Update go.yml
Luc4592 May 7, 2023
b792845
Update go.yml
Luc4592 May 7, 2023
e596a7a
Delete Docker.yml
Luc4592 May 8, 2023
b6ff6a6
Create docker
Luc4592 May 9, 2023
e863e2d
Update go.yml
Luc4592 May 9, 2023
b527ae2
Update go.yml
Luc4592 May 9, 2023
4cea5e3
Update go.yml
Luc4592 May 9, 2023
65a0f82
Update go.yml
Luc4592 May 9, 2023
6589734
Update docker
Luc4592 May 9, 2023
42154b4
Update go.yml
Luc4592 May 9, 2023
90bfc4b
Update go.yml
Luc4592 May 9, 2023
9577a29
Update go.yml
Luc4592 May 9, 2023
35119c2
Update go.yml
Luc4592 May 9, 2023
5401e7f
Rename docker to docker.yml
Luc4592 May 9, 2023
aebb8a6
Update docker.yml
Luc4592 May 9, 2023
96d7747
Update go.yml
Luc4592 May 9, 2023
699d3b0
Update docker.yml
Luc4592 May 9, 2023
3fe1022
Create snyk.yml
Luc4592 Jun 5, 2023
5b476a9
Update go.yml
Luc4592 Jun 5, 2023
e3eb416
Delete snyk.yml
Luc4592 Jun 5, 2023
b19862f
Update go.yml
Luc4592 Jun 5, 2023
2f329c1
Create snyk.yml
Luc4592 Jun 21, 2023
1548157
Update snyk.yml
Luc4592 Jun 21, 2023
356b22c
Update snyk.yml
Luc4592 Jun 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Docker

on:
workflow_call:

jobs:

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

- name: setup Docker Build
uses: docker/[email protected]

- name: Download a Build Artifact
uses: actions/[email protected]
with:
# Artifact name
name: programa

- name: Docker Login
# You may pin to the exact commit or the version.
# uses: docker/login-action@49ed152c8eca782a232dede0303416e8f356c37b
uses: docker/[email protected]
with:
# Username used to log against the Docker registry
username: luc4592
# Password or personal access token used to log against the Docker registry
password: ${{ secrets.PASSWD }}

- name: Build and push Docker images
# You may pin to the exact commit or the version.
# uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
uses: docker/[email protected]
with:
# Build's context is the set of files located in the specified PATH or URL
context: .
# Path to the Dockerfile
file: ./Dockerfile
# Push is a shorthand for --output=type=registry
push: true
# List of tags
tags: luc4592/go_ci:${{ github.ref_name }}
43 changes: 36 additions & 7 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,24 @@ name: Go

on:
push:
branches: [ Aula_1 ]
branches: [ '*' ]
pull_request:
branches: [ Aula_1 ]
branches: [ '*' ]

jobs:

test:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
env:
HOST: localhost
PORT: 5432
USER: root
PASSWORD: root
DBNAME: root
strategy:
matrix:
go_version: ['1.18', '1.17', '>=1.18']
os: ['ubuntu-latest', 'ubuntu-20.04']
steps:
- uses: actions/checkout@v3

Expand All @@ -30,14 +37,36 @@ jobs:
- name: Test
run: go test -v main_test.go

- name: Snyk
# You may pin to the exact commit or the version.
# uses: snyk/actions@b98d498629f1c368650224d6d212bf7dfa89e4bf
uses: snyk/[email protected]
with:
# Which Snyk command to run, defaults to test
command: # Additional arguments to pass to Snyk
#args: # optional
# Output a snyk.json file with results if running the test command
#json: # optional


build:
needs: test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ['ubuntu-latest', 'ubuntu-18.04']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build
run: go build -v main.go


- name: Upload a Build Artifact
uses: actions/[email protected]
with:
# Artifact name
name: programa
# A file, directory or wildcard pattern that describes what to upload
path: main

docker:
needs: build
uses: ./.github/workflows/docker.yml
secrets: inherit
12 changes: 12 additions & 0 deletions .github/workflows/snyk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Snyk
on: push
jobs:
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: RunSnyk to check for vulnerabilities
uses: snyk/actions/maven@master
continue-on-error: true
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM ubuntu:latest

EXPOSE 8000

WORKDIR /app

ENV HOST=localhost PORT=5432

ENV USER=root PASSWORD=root DBNAME=root

COPY ./main.exe main

CMD [ "./main" ]
5 changes: 3 additions & 2 deletions database/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package database

import (
"log"

"os"
"github.com/guilhermeonrails/api-go-gin/models"
"gorm.io/driver/postgres"
"gorm.io/gorm"
Expand All @@ -14,7 +14,8 @@ var (
)

func ConectaComBancoDeDados() {
stringDeConexao := "host=localhost user=root password=root dbname=root port=5432 sslmode=disable"

stringDeConexao := "host="+os.Getenv("HOST")+" user="+os.Getenv("USER")+" password="+os.Getenv("PASSWORD")+" dbname="+os.Getenv("DBNAME")+" port="+os.Getenv("PORT")+" sslmode=disable"
DB, err = gorm.Open(postgres.Open(stringDeConexao))
if err != nil {
log.Panic("Erro ao conectar com banco de dados")
Expand Down