From cd72097e026b5bb8b5d5c2be0651b37f7eadcb32 Mon Sep 17 00:00:00 2001 From: Vargha Csongor Date: Thu, 27 Mar 2025 20:46:25 +0100 Subject: [PATCH] move to new pipeline --- .github/workflows/auth-service-cd.yml | 52 ------------------- .github/workflows/db_adapter_ci.yml | 35 +++++++++++++ .../{backend-cd.yml => docker_build.yml} | 22 ++++---- .github/workflows/go_test.yml | 35 +++++++++++++ .github/workflows/lint.yml | 23 -------- .github/workflows/svelte_build.yml | 24 --------- .../{frontend-ci.yml => svelte_ci.yml} | 11 ++-- .github/workflows/svelte_test.yml | 36 +++++++++++++ .github/workflows/test.yml | 28 ---------- 9 files changed, 125 insertions(+), 141 deletions(-) delete mode 100644 .github/workflows/auth-service-cd.yml create mode 100644 .github/workflows/db_adapter_ci.yml rename .github/workflows/{backend-cd.yml => docker_build.yml} (76%) create mode 100644 .github/workflows/go_test.yml delete mode 100644 .github/workflows/lint.yml delete mode 100644 .github/workflows/svelte_build.yml rename .github/workflows/{frontend-ci.yml => svelte_ci.yml} (53%) create mode 100644 .github/workflows/svelte_test.yml delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/auth-service-cd.yml b/.github/workflows/auth-service-cd.yml deleted file mode 100644 index c862118..0000000 --- a/.github/workflows/auth-service-cd.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: Release Auth service to Docker Hub - -on: - pull_request: - paths: - - "cmd/auth/**" - - "pkg/**" - - "deployment/auth-service/**" - - ".github/workflows/auth-service-cd.yml" - -jobs: - docker: - name: Build and Push Auth-service 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}}:cmd/auth" - tags: vcscsvcscs/gheritage-auth-service:${{steps.create_image_tag.outputs.result}} - platforms: linux/amd64, linux/arm64 diff --git a/.github/workflows/db_adapter_ci.yml b/.github/workflows/db_adapter_ci.yml new file mode 100644 index 0000000..c27cc76 --- /dev/null +++ b/.github/workflows/db_adapter_ci.yml @@ -0,0 +1,35 @@ +name: Database Adapter Continues 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/backend-cd.yml b/.github/workflows/docker_build.yml similarity index 76% rename from .github/workflows/backend-cd.yml rename to .github/workflows/docker_build.yml index 8635e63..82985a9 100644 --- a/.github/workflows/backend-cd.yml +++ b/.github/workflows/docker_build.yml @@ -1,12 +1,14 @@ -name: Release Backend service to Docker Hub +name: Release to Docker Hub on: - pull_request: - paths: - - "cmd/backend/**" - - "pkg/**" - - "deployment/backend/**" - - ".github/workflows/backend-cd.yml" + workflow_call: + inputs: + service-name: + required: true + type: string + working-directory: + required: true + type: string jobs: docker: @@ -47,6 +49,6 @@ jobs: uses: docker/build-push-action@v5 with: push: true - context: "{{defaultContext}}:cmd/backend" - tags: vcscsvcscs/gheritage-backend-service:${{steps.create_image_tag.outputs.result}} - platforms: linux/amd64, linux/arm64 + 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/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index d1c32ed..0000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Go Lint - -on: - pull_request: - paths: - - "cmd/**" - - "pkg/**" - -jobs: - golangci: - name: lint - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version: '1.23' - cache: false - - name: golangci-lint - uses: golangci/golangci-lint-action@v4 - with: - version: latest - working-directory: . diff --git a/.github/workflows/svelte_build.yml b/.github/workflows/svelte_build.yml deleted file mode 100644 index 541ad80..0000000 --- a/.github/workflows/svelte_build.yml +++ /dev/null @@ -1,24 +0,0 @@ -on: - workflow_call: - inputs: - working-directory: - required: true - type: string - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: '21.x' - - name: Install dependencies - run: | - cd ${{ inputs.working-directory }} - npm ci - - name: Build - run: | - cd ${{ inputs.working-directory }} - npm run build \ No newline at end of file diff --git a/.github/workflows/frontend-ci.yml b/.github/workflows/svelte_ci.yml similarity index 53% rename from .github/workflows/frontend-ci.yml rename to .github/workflows/svelte_ci.yml index 27aaa3b..17ab5fb 100644 --- a/.github/workflows/frontend-ci.yml +++ b/.github/workflows/svelte_ci.yml @@ -1,15 +1,18 @@ name: Frontend Continuous Integration + on: pull_request: paths: - - "cmd/frontend/**" + - "apps/app**" + jobs: lint: uses: ./.github/workflows/svelte_lint.yml with: - working-directory: 'cmd/frontend' + working-directory: 'apps/app' + build: needs: lint - uses: ./.github/workflows/svelte_build.yml + uses: ./.github/workflows/svelte_test.yml with: - working-directory: 'cmd/frontend' + working-directory: 'apps/app' \ No newline at end of file diff --git a/.github/workflows/svelte_test.yml b/.github/workflows/svelte_test.yml new file mode 100644 index 0000000..55fb121 --- /dev/null +++ b/.github/workflows/svelte_test.yml @@ -0,0 +1,36 @@ +on: + workflow_call: + inputs: + working-directory: + required: true + type: string + +jobs: + test: + runs-on: ubuntu-latest + permissions: + # Required to checkout the code + contents: read + # Required to put a comment into the pull-request + pull-requests: write + + steps: + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '21.x' + - name: Install dependencies + run: | + cd ${{ inputs.working-directory }} + npm ci + - name: 'Test' + run: | + cd ${{ inputs.working-directory }} + npx vitest --coverage.enabled true + - name: 'Report Coverage' + # Set if: always() to also generate the report if tests are failing + # Only works if you set `reportOnFailure: true` in your vite config as specified above + if: always() + uses: davelosert/vitest-coverage-report-action@v2 + with: + working-directory: ${{ inputs.working-directory }} \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 5c61b2e..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Go Test - -on: - pull_request: - paths: - - "cmd/**" - - "pkg/**" - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Setup Go 1.23.x' - uses: actions/setup-go@v5 - with: - go-version: '1.23.x' - - - name: Display Go version - run: go version - - - name: Install dependencies - run: | - go get ./... - - - name: Run tests - run: | - go test ./... \ No newline at end of file