diff --git a/.github/workflows/db_adapter_ci.yml b/.github/workflows/db_adapter_ci.yml new file mode 100644 index 0000000..4add423 --- /dev/null +++ b/.github/workflows/db_adapter_ci.yml @@ -0,0 +1,31 @@ +name: Frontend Continuous Integration +on: + pull_request: + paths: + - "apps/db-adapter**" +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: '1.24' + cache: false + - name: golangci-lint + uses: golangci/golangci-lint-action@v4 + with: + version: latest + working-directory: 'apps/db-adapter' + test: + uses: ./.github/workflows/go_test.yml + needs: golangci + with: + working-directory: 'apps/db-adapter' + build: + needs: test + uses: ./.github/workflows/docker_build.yml + with: + working-directory: 'apps/db-adapter' + service-name: 'gheritage-db-adapter' diff --git a/.github/workflows/docker_build.yml b/.github/workflows/docker_build.yml new file mode 100644 index 0000000..82985a9 --- /dev/null +++ b/.github/workflows/docker_build.yml @@ -0,0 +1,54 @@ +name: Release to Docker Hub + +on: + workflow_call: + inputs: + service-name: + required: true + type: string + working-directory: + required: true + type: string + +jobs: + docker: + name: Build and Push Backend image to Docker Hub + runs-on: ubuntu-latest + steps: + - uses: actions/github-script@v6 + id: create_image_tag + with: + script: | + if(github.ref == 'refs/heads/main') { + return 'latest'; + } else if(context.issue.number) { + return "pr" + context.issue.number; + } else { + return "pr" + ( + await github.rest.repos.listPullRequestsAssociatedWithCommit({ + commit_sha: context.sha, + owner: context.repo.owner, + repo: context.repo.repo, + }) + ).data[0].number; + } + result-encoding: string + - name: Image tag + run: echo '${{steps.create_image_tag.outputs.result}}' + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v5 + with: + push: true + context: "{{defaultContext}}:${{ inputs.working-directory }}" + tags: vcscsvcscs/${{ inputs.service-name }}:${{steps.create_image_tag.outputs.result}} + platforms: linux/amd64, linux/arm64 \ No newline at end of file diff --git a/.github/workflows/go_test.yml b/.github/workflows/go_test.yml new file mode 100644 index 0000000..c19bbfa --- /dev/null +++ b/.github/workflows/go_test.yml @@ -0,0 +1,35 @@ +name: Go Test + +on: + workflow_call: + inputs: + working-directory: + required: true + type: string + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup Go 1.24.x' + uses: actions/setup-go@v5 + with: + go-version: '1.24.1' + + - name: Display Go version + run: go version + + - name: Install dependencies + run: | + go get ./${{ inputs.working-directory }}/... + + - name: Run tests + run: | + go test ./${{ inputs.working-directory }}/... -json > TestResults.json + + - name: Upload Go test results + uses: actions/upload-artifact@v4 + with: + name: Go-Test-results + path: TestResults.json \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/svelte_ci.yml similarity index 70% rename from .github/workflows/ci.yml rename to .github/workflows/svelte_ci.yml index 9b92852..4fd9071 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/svelte_ci.yml @@ -2,14 +2,14 @@ name: Frontend Continuous Integration on: pull_request: paths: - - "app/**" + - "apps/app**" jobs: lint: uses: ./.github/workflows/svelte_lint.yml with: - working-directory: 'app' + working-directory: 'apps/app' build: needs: lint uses: ./.github/workflows/svelte_test.yml with: - working-directory: 'app' + working-directory: 'apps/app' diff --git a/compose.yaml b/compose.yaml index be889aa..9d2d851 100644 --- a/compose.yaml +++ b/compose.yaml @@ -37,6 +37,24 @@ services: environment: - QUICK_CONNECT_MG_HOST=memgraph - QUICK_CONNECT_MG_PORT=7687 + db-adapter: + image: vcscsvcscs/gheritage-db-adapter:latest + container_name: db-adapter + ports: + - "8080:8080" + depends_on: + - memgraph + environment: + - MEMGRAPH_HOST=memgraph + - MEMGRAPH_PORT=7687 + - MEMGRAPH_USER= + - MEMGRAPH_PASSWORD= + healthcheck: + test: ["CMD-SHELL", "curl --fail http://localhost:8080/health || exit 1"] + interval: 10s + timeout: 5s + retries: 3 + start_period: 0s volumes: mg_lib: driver: local @@ -55,4 +73,4 @@ volumes: driver_opts: type: 'none' o: 'bind' - device: '/data/memgraph/etc' \ No newline at end of file + device: '/data/memgraph/etc'