Merge branch 'main' into dependabot/go_modules/github.com/gorilla/mux-1.8.1
This commit is contained in:
2
.github/workflows/docker-image.yml
vendored
2
.github/workflows/docker-image.yml
vendored
@@ -7,7 +7,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3.5.3
|
- uses: actions/checkout@v4.1.1
|
||||||
- name: Build the Docker image
|
- name: Build the Docker image
|
||||||
run: docker build . --file Dockerfile --tag yosoy-local:latest
|
run: docker build . --file Dockerfile --tag yosoy-local:latest
|
||||||
- name: Run simple integration test
|
- name: Run simple integration test
|
||||||
|
|||||||
10
.github/workflows/docker-publish.yml
vendored
10
.github/workflows/docker-publish.yml
vendored
@@ -15,16 +15,16 @@ jobs:
|
|||||||
contents: read
|
contents: read
|
||||||
steps:
|
steps:
|
||||||
- name: Check out the repo
|
- name: Check out the repo
|
||||||
uses: actions/checkout@v3.5.3
|
uses: actions/checkout@v4.1.1
|
||||||
|
|
||||||
- name: Log in to Docker Hub
|
- name: Log in to Docker Hub
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
||||||
|
|
||||||
- name: Log in to the Container registry
|
- name: Log in to the Container registry
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
@@ -32,7 +32,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Extract metadata (tags, labels) for Docker
|
- name: Extract metadata (tags, labels) for Docker
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v4
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
images: |
|
images: |
|
||||||
lukasz/yosoy
|
lukasz/yosoy
|
||||||
@@ -44,7 +44,7 @@ jobs:
|
|||||||
type=semver,pattern={{major}}
|
type=semver,pattern={{major}}
|
||||||
|
|
||||||
- name: Build and push Docker images
|
- name: Build and push Docker images
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: true
|
push: true
|
||||||
|
|||||||
2
.github/workflows/go.yml
vendored
2
.github/workflows/go.yml
vendored
@@ -6,7 +6,7 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3.5.3
|
- uses: actions/checkout@v4.1.1
|
||||||
|
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v4
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@@ -71,7 +70,7 @@ func handler(w http.ResponseWriter, req *http.Request) {
|
|||||||
response.Files = make(map[string]string)
|
response.Files = make(map[string]string)
|
||||||
files := strings.Split(showFiles, ",")
|
files := strings.Split(showFiles, ",")
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
bytes, err := ioutil.ReadFile(file)
|
bytes, err := os.ReadFile(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Could not read file %v: %v\n", file, err)
|
log.Printf("Could not read file %v: %v\n", file, err)
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
@@ -29,8 +30,12 @@ func TestHandler(t *testing.T) {
|
|||||||
t.Errorf("handler returned wrong status code: got %v want %v", status, http.StatusOK)
|
t.Errorf("handler returned wrong status code: got %v want %v", status, http.StatusOK)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result := rr.Result()
|
||||||
|
buf := new(bytes.Buffer)
|
||||||
|
buf.ReadFrom(result.Body)
|
||||||
|
|
||||||
var response response
|
var response response
|
||||||
json.Unmarshal(rr.Body.Bytes(), &response)
|
json.Unmarshal(buf.Bytes(), &response)
|
||||||
|
|
||||||
// test response
|
// test response
|
||||||
assert.Equal(t, 1, response.Counter)
|
assert.Equal(t, 1, response.Counter)
|
||||||
@@ -43,5 +48,5 @@ func TestHandler(t *testing.T) {
|
|||||||
assert.NotEmpty(t, response.Files[".gitignore"])
|
assert.NotEmpty(t, response.Files[".gitignore"])
|
||||||
|
|
||||||
// test cors
|
// test cors
|
||||||
assert.Contains(t, rr.HeaderMap["Access-Control-Allow-Origin"], "*")
|
assert.Contains(t, result.Header["Access-Control-Allow-Origin"], "*")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user