diff --git a/.github/workflows/robot.yml b/.github/workflows/robot.yml index 044d5e3a..02b485e5 100644 --- a/.github/workflows/robot.yml +++ b/.github/workflows/robot.yml @@ -14,11 +14,14 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Pull images - run: | - cp .env.example .env - docker compose version - docker compose pull + - name: Robot cache + uses: actions/setup-python@v4 + with: + python-version: '3.9' + cache: 'pip' + + - name: Install robot + run: pip install -r requirements.txt - name: Docker cache uses: satackey/action-docker-layer-caching@v0.0.11 @@ -26,18 +29,18 @@ jobs: - name: Start the service run: | - docker compose up -d back postgres traefik meilisearch --wait + cp .env.example .env + docker compose -f docker-compose.build.yml up -d auth postgres traefik --wait - name: Perform healthchecks run: | docker compose ps -a docker compose logs - wget --retry-connrefused --retry-on-http-error=502 http://localhost:8901/api/health || (docker compose logs && exit 1) + # wget --retry-connrefused --retry-on-http-error=502 http://localhost:8901/api/health || (docker compose logs && exit 1) - name: Run robot tests run: | - pip install -r back/tests/robot/requirements.txt - robot -d out back/tests/robot/ + robot -d out $(find -type d -name robot) - name: Show logs if: failure() diff --git a/auth/Dockerfile b/auth/Dockerfile index 2142fb98..5c1a1b93 100644 --- a/auth/Dockerfile +++ b/auth/Dockerfile @@ -7,7 +7,8 @@ RUN go install github.com/swaggo/swag/cmd/swag@latest COPY go.mod go.sum ./ RUN go mod download -COPY sqlc.yaml sql ./ +COPY sqlc.yaml ./ +COPY sql ./sql RUN sqlc generate COPY . . diff --git a/auth/main.go b/auth/main.go index e4713d74..abb0f712 100644 --- a/auth/main.go +++ b/auth/main.go @@ -79,6 +79,7 @@ func OpenDatabase() (*pgxpool.Pool, error) { config.ConnConfig.RuntimeParams["search_path"] = schema } + fmt.Printf("Connecting to database with %v\n", config) db, err := pgxpool.NewWithConfig(ctx, config) if err != nil { fmt.Printf("Could not connect to database, check your env variables!") @@ -143,7 +144,7 @@ func main() { db, err := OpenDatabase() if err != nil { - e.Logger.Fatal("Could not open databse: %v", err) + e.Logger.Fatal("Could not open databse: ", err) return } @@ -152,7 +153,7 @@ func main() { } conf, err := LoadConfiguration(h.db) if err != nil { - e.Logger.Fatal("Could not load configuration: %v", err) + e.Logger.Fatal("Could not load configuration: ", err) return } h.config = conf diff --git a/auth/robot/auth.resource b/auth/robot/auth.resource index 0c36d6f2..32f284a0 100644 --- a/auth/robot/auth.resource +++ b/auth/robot/auth.resource @@ -1,7 +1,7 @@ *** Settings *** Documentation Common things to handle rest requests -Library REST http://localhost:8901/api +Library REST http://localhost:8901/auth *** Keywords *** diff --git a/auth/robot/sessions.robot b/auth/robot/sessions.robot index b695f39f..d5b880d1 100644 --- a/auth/robot/sessions.robot +++ b/auth/robot/sessions.robot @@ -1,7 +1,7 @@ *** Settings *** Documentation Tests of the /sessions route. -Resource ../auth.resource +Resource ./auth.resource *** Test Cases *** diff --git a/auth/robot/users.robot b/auth/robot/users.robot index 3d51bd93..96d8b3f9 100644 --- a/auth/robot/users.robot +++ b/auth/robot/users.robot @@ -2,7 +2,7 @@ Documentation Tests of the /users route. ... Ensures that the user can authenticate on kyoo. -Resource ../auth.resource +Resource ./auth.resource *** Test Cases *** diff --git a/docker-compose.build.yml b/docker-compose.build.yml index a883166c..a5114db5 100644 --- a/docker-compose.build.yml +++ b/docker-compose.build.yml @@ -60,6 +60,23 @@ services: - "traefik.enable=true" - "traefik.http.routers.front.rule=PathPrefix(`/`)" + auth: + build: ./auth + restart: on-failure + depends_on: + postgres: + condition: service_healthy + env_file: + - ./.env + labels: + - "traefik.enable=true" + - "traefik.http.routers.auth.rule=PathPrefix(`/auth/`)" + - "traefik.http.routers.auth.middlewares=auth-sp" + - "traefik.http.middlewares.auth-sp.stripprefix.prefixes=/auth" + - "traefik.http.middlewares.auth-sp.stripprefix.forceSlash=false" + profiles: + - "v5" + scanner: build: ./scanner restart: on-failure diff --git a/back/tests/robot/requirements.txt b/requirements.txt similarity index 100% rename from back/tests/robot/requirements.txt rename to requirements.txt diff --git a/shell.nix b/shell.nix index d665739e..3d413798 100644 --- a/shell.nix +++ b/shell.nix @@ -11,6 +11,9 @@ dataclasses-json msgspec langcodes + + robotframework + # restinstance needs to be packaged ]); dotnet = with pkgs.dotnetCorePackages; combinePackages [