Fixing ci :)

* wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* ci wip

* meili env var in example dotenv
This commit is contained in:
Bluub
2023-12-08 12:31:44 +01:00
committed by GitHub
parent 80329e240e
commit a47f8744f8
8 changed files with 287 additions and 166 deletions

View File

@@ -20,7 +20,5 @@ API_KEYS=SCOROTEST,ROBOTO,SCORO
API_KEY_SCORO_TEST=SCOROTEST API_KEY_SCORO_TEST=SCOROTEST
API_KEY_ROBOT=ROBOTO API_KEY_ROBOT=ROBOTO
API_KEY_SCORO=SCORO API_KEY_SCORO=SCORO
MEILI_HTTP_ADDR="http://meilisearch:7700"
MEILI_MASTER_KEY="ghvjkgisbgkbgskegblfqbgjkebbhgwkjfb" MEILI_MASTER_KEY="ghvjkgisbgkbgskegblfqbgjkebbhgwkjfb"
# vi: ft=sh # vi: ft=sh

View File

@@ -1,166 +1,18 @@
name: CI name: Deploy
on: on:
pull_request:
types:
- closed
branches:
- main
push: push:
branches: branches:
- '*' - main
pull_request:
branches: [ main ]
jobs: jobs:
deployment:
## Build Back ##
Build_Back:
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 10 if: github.event.pull_request.merged == true
defaults:
run:
working-directory: ./back
environment: Staging
steps:
- uses: actions/checkout@v3
- name: Build Docker
run: docker build -t testback .
## Build App ##
Check_Front:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./front
environment: Staging
steps:
- uses: actions/checkout@v3
- name: Install Yarn
run: npm install -g yarn
- name: Install dependencies
run: yarn install
- name: Type Check
run: yarn tsc
- name: Check Prettier
run: yarn pretty:check .
- name: Run Linter
run: yarn lint
Build_Front:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./front
environment: Staging
steps:
- uses: actions/checkout@v3
- name: Install Yarn
run: npm install -g yarn
- name: Install dependencies
run: yarn install
- name: 🏗 Setup Expo
uses: expo/expo-github-action@v8
with:
expo-version: latest
eas-version: latest
token: ${{ secrets.EXPO_TOKEN }}
- name: Build Web App
uses: docker/build-push-action@v3
with:
context: ./front
push: false
tags: ${{steps.meta_front.outputs.tags}}
build-args: |
API_URL=${{secrets.API_URL}}
SCORO_URL=${{secrets.SCORO_URL}}
- name: Build Android APK
run: |
eas build -p android --profile production --local --non-interactive
mv *.apk chromacase.apk
- name: Upload Artifact
if: github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v3
with:
name: chromacase.apk
path: front/
## Test Backend ##
Test_Back:
runs-on: ubuntu-latest
timeout-minutes: 15
needs: [ Build_Back ]
environment: Staging
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: Copy env file to github secret env file
run: cp .env.example .env
- name: Start the service
run: docker-compose up -d back db
- name: Perform healthchecks
run: |
docker-compose ps -a
docker-compose logs
wget --retry-connrefused http://localhost:3000 || (docker-compose logs && exit 1)
- name: Run scorometer tests
run: |
pip install -r scorometer/requirements.txt
export API_KEY_SCORO_TEST=SCOROTEST
export API_KEY_SCORO=SCORO
cd scorometer/tests && ./runner.sh
- name: Run robot tests
run: |
export API_KEY_ROBOT=ROBOTO
pip install -r back/test/robot/requirements.txt
robot -d out back/test/robot/
- uses: actions/upload-artifact@v3
if: always()
with:
name: results
path: out
- name: Write results to Pull Request and Summary
if: always() && github.event_name == 'pull_request'
uses: joonvena/robotframework-reporter-action@v2.1
with:
report_path: out/
gh_access_token: ${{ secrets.GITHUB_TOKEN }}
only_summary: false
- name: Write results to Summary
if: always() && github.event_name != 'pull_request'
uses: joonvena/robotframework-reporter-action@v2.1
with:
report_path: out/
gh_access_token: ${{ secrets.GITHUB_TOKEN }}
only_summary: true
- name: Remove .env && stop the service
run: docker-compose down && rm .env
## Test App ##
## Deployement ##
Deployement_Docker:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
environment: Production
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
@@ -205,6 +57,7 @@ jobs:
build-args: | build-args: |
API_URL=${{secrets.API_URL}} API_URL=${{secrets.API_URL}}
SCORO_URL=${{secrets.SCORO_URL}} SCORO_URL=${{secrets.SCORO_URL}}
- name: Docker meta scorometer - name: Docker meta scorometer
id: meta_scorometer id: meta_scorometer
uses: docker/metadata-action@v4 uses: docker/metadata-action@v4

98
.github/workflows/back.yml vendored Normal file
View File

@@ -0,0 +1,98 @@
name: "Back"
on:
pull_request:
branches: [ main ]
jobs:
changes:
runs-on: ubuntu-latest
# Required permissions
permissions:
pull-requests: read
# Set job outputs to values from filter step
outputs:
backend: ${{ steps.filter.outputs.backend }}
frontend: ${{ steps.filter.outputs.frontend }}
scoro: ${{ steps.filter.outputs.scoro }}
steps:
# For pull requests it's not necessary to checkout the code
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
backend:
- 'backend/**'
frontend:
- 'frontend/**'
scoro:
- 'scorometer/**'
back_build:
runs-on: ubuntu-latest
timeout-minutes: 10
needs: changes
if: ${{ needs.changes.outputs.backend == 'true' }}
defaults:
run:
working-directory: ./back
steps:
- uses: actions/checkout@v3
- name: Build Docker
run: docker build -t testback .
back_test:
runs-on: ubuntu-latest
timeout-minutes: 15
needs: [ back_build ]
if: ${{ needs.changes.outputs.frontend == 'true' }}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: Copy env file to github secret env file
run: cp .env.example .env
- name: Build and start the service
run: docker-compose up -d meilisearch back db
- name: Perform healthchecks
run: |
docker-compose ps -a
docker-compose logs
wget --retry-connrefused http://localhost:3000 || (docker-compose logs && exit 1)
- name: Run robot tests
run: |
export API_KEY_ROBOT=ROBOTO
pip install -r back/test/robot/requirements.txt
robot -d out back/test/robot/
- uses: actions/upload-artifact@v3
if: always()
with:
name: results
path: out
- name: Write results to Pull Request and Summary
if: always() && github.event_name == 'pull_request'
uses: joonvena/robotframework-reporter-action@v2.1
with:
report_path: out/
gh_access_token: ${{ secrets.GITHUB_TOKEN }}
only_summary: false
- name: Write results to Summary
if: always() && github.event_name != 'pull_request'
uses: joonvena/robotframework-reporter-action@v2.1
with:
report_path: out/
gh_access_token: ${{ secrets.GITHUB_TOKEN }}
only_summary: true
- name: stop the service
run: docker-compose down

95
.github/workflows/front.yml vendored Normal file
View File

@@ -0,0 +1,95 @@
name: "Front"
on:
pull_request:
branches: [ main ]
jobs:
changes:
runs-on: ubuntu-latest
# Required permissions
permissions:
pull-requests: read
# Set job outputs to values from filter step
outputs:
backend: ${{ steps.filter.outputs.backend }}
frontend: ${{ steps.filter.outputs.frontend }}
scoro: ${{ steps.filter.outputs.scoro }}
steps:
# For pull requests it's not necessary to checkout the code
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
backend:
- 'backend/**'
frontend:
- 'frontend/**'
scoro:
- 'scorometer/**'
front_check:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./front
needs: changes
if: ${{ needs.changes.outputs.frontend == 'true' }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'yarn'
cache-dependency-path: front/yarn.lock
- run: yarn install --frozen-lockfile
- name: type check
run: yarn tsc
- name: prettier
run: yarn pretty:check .
- name: eslint
run: yarn lint
front_build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./front
if: ${{ needs.changes.outputs.frontend == 'true' }}
needs: [ front_check ]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'yarn'
cache-dependency-path: front/yarn.lock
- run: yarn install --frozen-lockfile
- name: 🏗 Setup Expo
uses: expo/expo-github-action@v8
with:
expo-version: latest
eas-version: latest
token: ${{ secrets.EXPO_TOKEN }}
- name: Build Web App
uses: docker/build-push-action@v3
with:
context: ./front
push: false
tags: ${{steps.meta_front.outputs.tags}}
build-args: |
API_URL=${{secrets.API_URL}}
SCORO_URL=${{secrets.SCORO_URL}}
- name: Build Android APK
run: |
eas build -p android --profile production --local --non-interactive
mv *.apk chromacase.apk
- name: Upload Artifact
if: github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v3
with:
name: chromacase.apk
path: front/

60
.github/workflows/scoro.yml vendored Normal file
View File

@@ -0,0 +1,60 @@
name: "Scoro"
on:
pull_request:
branches: [ main ]
jobs:
changes:
runs-on: ubuntu-latest
# Required permissions
permissions:
pull-requests: read
# Set job outputs to values from filter step
outputs:
backend: ${{ steps.filter.outputs.backend }}
frontend: ${{ steps.filter.outputs.frontend }}
scoro: ${{ steps.filter.outputs.scoro }}
steps:
# For pull requests it's not necessary to checkout the code
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
backend:
- 'backend/**'
frontend:
- 'frontend/**'
scoro:
- 'scorometer/**'
scoro_test:
runs-on: ubuntu-latest
needs: changes
if: ${{ needs.changes.outputs.scoro == 'true' }}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: Copy env file to github secret env file
run: cp .env.example .env
- name: Build and start the service
run: docker-compose up -d meilisearch back db
- name: Perform healthchecks
run: |
docker-compose ps -a
docker-compose logs
wget --retry-connrefused http://localhost:3000 || (docker-compose logs && exit 1)
- name: Run scorometer tests
run: |
export API_KEY_SCORO_TEST=SCOROTEST
export API_KEY_SCORO=SCORO
pip install -r scorometer/requirements.txt
cd scorometer/tests && ./runner.sh
- name: stop the service
run: docker-compose down

View File

@@ -22,6 +22,9 @@ services:
depends_on: depends_on:
db: db:
condition: service_healthy condition: service_healthy
meilisearch:
condition: service_healthy
env_file: env_file:
- .env - .env
@@ -94,3 +97,10 @@ services:
- meilisearch:/meili_data - meilisearch:/meili_data
env_file: env_file:
- .env - .env
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:7700/health"]
interval: 10s
timeout: 10s
retries: 5

View File

@@ -1,7 +1,3 @@
networks:
loki:
volumes: volumes:
db: db:
scoro_logs: scoro_logs:
@@ -17,11 +13,15 @@ services:
depends_on: depends_on:
db: db:
condition: service_healthy condition: service_healthy
meilisearch:
condition: service_healthy
env_file: env_file:
- .env - .env
volumes: volumes:
- ./assets:/assets - ./assets:/assets
- ./data:/data - ./data:/data
scorometer: scorometer:
build: ./scorometer build: ./scorometer
ports: ports:
@@ -62,10 +62,19 @@ services:
- .env - .env
meilisearch: meilisearch:
image: getmeili/meilisearch:v1.4 image: getmeili/meilisearch:v1.5
ports: ports:
- "7700:7700" - "7700:7700"
volumes: volumes:
- meilisearch:/meili_data - meilisearch:/meili_data
env_file: env_file:
- .env - .env
healthcheck:
test:
- CMD
- wget
- '--no-verbose'
- '--spider'
- 'http://localhost:7700/health'
retries: 3
timeout: 5s

View File

@@ -367,8 +367,6 @@ def handleStartMessage(start_message: StartMessage):
try: try:
r = requests.get(f"{BACK_URL}/song/{song_id}", headers=auth_header) r = requests.get(f"{BACK_URL}/song/{song_id}", headers=auth_header)
r.raise_for_status() r.raise_for_status()
# Delete the guest account after getting song
requests.delete(f"{BACK_URL}/auth/me", headers=auth_header)
song_path = r.json()["midiPath"] song_path = r.json()["midiPath"]
song_path = song_path.replace("/assets/musics/", MUSICS_FOLDER) song_path = song_path.replace("/assets/musics/", MUSICS_FOLDER)
except Exception as e: except Exception as e: