Skip to content

Commit

Permalink
Feature ETP-732: Add pipeline for test Etendo compilation
Browse files Browse the repository at this point in the history
Add Github credentials vars in gradle.properties.template. Add Git Police Action.
  • Loading branch information
valeg-etendo committed Nov 12, 2024
1 parent db9fff1 commit 159edbf
Show file tree
Hide file tree
Showing 7 changed files with 523 additions and 26 deletions.
19 changes: 14 additions & 5 deletions .github/workflows/auto-reviewer.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
name: Auto Reviewer

on:
pull_request:
types: [opened, reopened, synchronize]
workflow_run:
workflows: [Git Police]
types:
- completed

jobs:
make-review:
if: github.head_ref != 'develop'
if: github.head_ref != 'develop' && github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
env:
PULL_REQUEST: ${{ github.event.pull_request.number }}
PROJECT: ${{ github.event.repository.owner.login }}
REPO_SLUG: ${{ github.event.repository.name }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
Expand All @@ -20,21 +21,29 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2

- name: Fetch pull request number
id: fetch-pr
run: |
PR_NUMBER=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ env.PROJECT }}/${{ env.REPO_SLUG }}/pulls?head=${{ env.PROJECT }}:${{ github.head_ref }}" \
| jq '.[0].number')
echo "PULL_REQUEST=$PR_NUMBER" >> $GITHUB_ENV
- name: Run Docker container
id: run-docker
run: |
printenv
echo "-------------------------------------------------------------------------"
echo ${{ env.DOCKERHUB_PASSWORD }} | docker login --username "${{ env.DOCKERHUB_USERNAME }}" --password-stdin
docker run -d -p 5000:5000 -e REPO_API_TOKEN="${{ env.ETENDOBOT_TOKEN }}" -e PULL_REQUEST=${{ env.PULL_REQUEST }} -e PROJECT=${{ env.PROJECT }} -e REPO_SLUG=${{ env.REPO_SLUG }} -e OPENAI_API_KEY="${{ env.OPENAI_API_KEY }}" etendo/code-reviewer:latest
- name: Make Reviewer API call
id: call-api
run: |
sleep 10s
response=$(curl -s -o response.txt -w "%{http_code}" -X GET http://localhost:5000/review/github)
if [ $response -ne 200 ]; then
echo "API call failed with status code $response. This is likely an error related to the PR data, or an internal API error"
echo "Response text:"
cat response.txt
exit 1
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/git-police.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Git Police

on:
pull_request:
types: [opened, reopened, synchronize]

jobs:
git-police:
name: Git Police
if: github.head_ref != 'develop'
runs-on: ubuntu-latest
env:
PR_ID: ${{ github.event.pull_request.number }}
REPO_NAME: ${{ github.event.repository.name }}
ETENDOBOT_TOKEN: ${{ secrets.ETENDOBOT_TOKEN }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Run Docker container
id: run-docker
run: |
printenv
echo "-------------------------------------------------------------------------"
echo ${{ env.DOCKERHUB_PASSWORD }} | docker login --username "${{ env.DOCKERHUB_USERNAME }}" --password-stdin
docker run -d -p 5000:5000 -e REPO_TOKEN="${{ env.ETENDOBOT_TOKEN }}" -e PR_ID=${{ env.PR_ID }} -e REPO_NAME=${{ env.REPO_NAME }} etendo/gitpolice:latest
- name: Git Police API call
id: call-api
run: |
sleep 10s
response=$(curl -s -o response.txt -w "%{http_code}" -X GET http://localhost:5000/api/github)
if [ $response -ne 200 ]; then
echo "API call failed with status code $response. This is likely an error related to the PR data, or an internal API error"
echo "Response text:"
cat response.txt
exit 1
fi
if ! grep -q "Valid branch name and correct destination" response.txt; then
echo "Git Police check failed: response does not contain 'Valid branch name and correct destination'"
echo "Full response:"
cat response.txt
exit 1
fi
echo "API call successful with status code $response"
echo "Response text"
cat response.txt
8 changes: 5 additions & 3 deletions gradle.properties.template
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
nexusUser = ""
nexusPassword = ""
nexusUser=
nexusPassword=
githubUser=
githubToken=

test.bbdd.url=
test.bbdd.sid=
Expand All @@ -8,4 +10,4 @@ test.bbdd.systemPassword=
test.bbdd.user=
test.bbdd.password=
org.gradle.daemon=false
org.gradle.jvmargs=-Xmx2g -XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.jvmargs=-Dfile.encoding=UTF-8
Loading

0 comments on commit 159edbf

Please sign in to comment.