Skip to content

feat/redesign-and-improvements #20

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

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
152 changes: 77 additions & 75 deletions .github/workflows/lint-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,89 +2,91 @@ name: lint-and-test

on:
pull_request:
branches:
- main
branches:
- main
workflow_dispatch:

jobs:
sanitize-branch-name:
runs-on: ubuntu-latest
outputs:
sanitized_ref: ${{ steps.sanitize.outputs.sanitized_ref }}
steps:
- name: sanitize-branch-name
id: sanitize
run: |
SANITIZED_REF=$(echo "${GITHUB_HEAD_REF}" | tr '[:upper:]' '[:lower:]' | tr -c 'a-z0-9' '-')
SANITIZED_REF=${SANITIZED_REF#-}
SANITIZED_REF=${SANITIZED_REF%-}
SANITIZED_REF=${SANITIZED_REF:0:63}
if [[ -z "$SANITIZED_REF" || "$SANITIZED_REF" =~ ^-+$ ]]; then
SANITIZED_REF="tmp-branch"
fi
echo "::set-output name=sanitized_ref::${SANITIZED_REF}"
shell: bash
env:
GITHUB_HEAD_REF: ${{ github.head_ref }}
sanitize-branch-name:
runs-on: ubuntu-latest
outputs:
sanitized_ref: ${{ steps.sanitize.outputs.sanitized_ref }}
steps:
- name: sanitize-branch-name
id: sanitize
run: |
SANITIZED_REF=$(echo "${GITHUB_HEAD_REF}" | tr '[:upper:]' '[:lower:]' | tr -c 'a-z0-9' '-')
SANITIZED_REF=${SANITIZED_REF#-}
SANITIZED_REF=${SANITIZED_REF%-}
SANITIZED_REF=${SANITIZED_REF:0:63}
if [[ -z "$SANITIZED_REF" || "$SANITIZED_REF" =~ ^-+$ ]]; then
SANITIZED_REF="tmp-branch"
fi
echo "::set-output name=sanitized_ref::${SANITIZED_REF}"
shell: bash
env:
GITHUB_HEAD_REF: ${{ github.head_ref }}

update-submodules:
name: update-submodules
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
submodules: false
update-submodules:
name: update-submodules
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
submodules: false

- name: update-submodules
id: update-submodules
run: |
git config --global url."https://github.com/".insteadOf "git@github.com:"
git submodule sync --recursive
git submodule update --init --remote --recursive
- name: update-submodules
id: update-submodules
run: |
git config --global url."https://github.com/".insteadOf "git@github.com:"
git submodule sync --recursive
git submodule update --init --remote --recursive

if [ -n "$(git status --porcelain)" ]; then
echo "Submodules have new commits. Committing and pushing..."
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git commit -am "chore: update submodules to latest main"
git push
else
echo "No submodule changes."
fi
if [ -n "$(git status --porcelain)" ]; then
echo "Submodules have new commits. Committing and pushing..."
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git commit -am "chore: update submodules to latest main"
git push
else
echo "No submodule changes."
fi

build-and-lint:
name: Build and Lint
runs-on: ubuntu-latest
needs: [sanitize-branch-name, update-submodules]
strategy:
fail-fast: true
matrix:
service: [ "admin-backend", "document-extractor", "rag-backend"]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
submodules: true
build-and-lint:
name: Build and Lint
runs-on: ubuntu-latest
needs: [sanitize-branch-name, update-submodules]
strategy:
fail-fast: true
matrix:
service: ["admin-backend", "document-extractor", "rag-backend"]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
submodules: true

- name: Set Docker Image Name
run: |
echo "IMAGE_NAME=${{ matrix.service }}:${{ needs.sanitize-branch-name.outputs.sanitized_ref }}-${{ github.run_number }}" >> $GITHUB_ENV
shell: bash
- name: Set Docker Image Name
run: |
echo "IMAGE_NAME=${{ matrix.service }}:${{ needs.sanitize-branch-name.outputs.sanitized_ref }}-${{ github.run_number }}" >> $GITHUB_ENV
shell: bash

- name: Build lint image
run: |
docker build -t $IMAGE_NAME --build-arg dev=1 --build-arg TAG=debug -f ${{ matrix.service }}/Dockerfile .
- name: Build lint image
run: |
docker build -t $IMAGE_NAME --build-arg dev=1 --build-arg TAG=debug -f ${{ matrix.service }}/Dockerfile .

- name: Generate lint report
run: |
docker run --rm --entrypoint make "$IMAGE_NAME" lint
- name: Generate lint report
run: |
docker run --rm --entrypoint make "$IMAGE_NAME" lint

- name: Run tests
run: |
docker run --rm --entrypoint make "$IMAGE_NAME" test
- name: Run tests
run: |
docker run --rm --entrypoint make "$IMAGE_NAME" test
Loading
Loading