This repository has been archived by the owner on Jan 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from rauldpm/10_add-gha_2.0.2
Add gha workflows
- Loading branch information
Showing
9 changed files
with
251 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Build Rasa model | ||
|
||
# Run only when the branch is merged into main branch and | ||
# the changes affects the model data | ||
on: | ||
push: | ||
branches: | ||
- "main" | ||
paths: | ||
- "data/**" | ||
- "config.yml" | ||
- "domain.yml" | ||
- "endpoints.yml" | ||
- "credentials.yml" | ||
|
||
jobs: | ||
build: | ||
name: Train model | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Docker buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 | ||
with: | ||
username: ${{ secrets.DOCKER_USER }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
# Train | ||
|
||
- name: Run container (train) | ||
run: docker run -v "$(pwd)/models:/app/models" rauldpm/tfg-rasa:build | ||
|
||
- name: Change model name | ||
run: mv models/*.tar.gz models/model.tar.gz | ||
|
||
# Upload file | ||
|
||
- id: "auth" | ||
uses: "google-github-actions/auth@v0" | ||
with: | ||
credentials_json: "${{ secrets.GCP_JSON_KEY }}" | ||
|
||
- name: "Set up Cloud SDK" | ||
uses: "google-github-actions/setup-gcloud@v0" | ||
|
||
- name: Deploy | ||
run: gsutil cp models/model.tar.gz gs://${{ secrets.GCP_BUCKET }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Build testing container | ||
|
||
# Build and push to DockerHub the testing container | ||
on: | ||
push: | ||
branches: | ||
- "main" | ||
paths: | ||
- "Docker/testing/**" | ||
|
||
jobs: | ||
build: | ||
name: Build model container | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Copy dockerfile | ||
run: cp Docker/testing/Dockerfile . | ||
|
||
- name: Docker buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 | ||
with: | ||
username: ${{ secrets.DOCKER_USER }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Build the Docker image | ||
run: docker build -t rauldpm/tfg-rasa:testing . | ||
|
||
- name: Docker Push | ||
run: docker push rauldpm/tfg-rasa:testing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Build container builder | ||
|
||
# Build and push to DockerHub the builder container | ||
# This container will reduce the train process (build-model.yml) | ||
on: | ||
push: | ||
branches: | ||
- "main" | ||
paths: | ||
- "Docker/build/**" | ||
|
||
jobs: | ||
build: | ||
name: Build model container | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Copy dockerfile | ||
run: cp Docker/build/Dockerfile . | ||
|
||
- name: Docker buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 | ||
with: | ||
username: ${{ secrets.DOCKER_USER }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Build the Docker image | ||
run: docker build -t rauldpm/tfg-rasa:build . | ||
|
||
- name: Docker Push | ||
run: docker push rauldpm/tfg-rasa:build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Tests | ||
|
||
# Build and push to DockerHub the builder container | ||
# This container will reduce the train process (build-model.yml) | ||
on: | ||
pull_request: | ||
branches: | ||
- "*" | ||
push: | ||
paths: | ||
- "data/**" | ||
- "config.yml" | ||
- "domain.yml" | ||
- "endpoints.yml" | ||
- "credentials.yml" | ||
|
||
jobs: | ||
build: | ||
name: Tests | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
# Train model | ||
|
||
- name: Docker buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 | ||
with: | ||
username: ${{ secrets.DOCKER_USER }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Run container (train) | ||
run: docker run -v "$(pwd)/models:/app/models" rauldpm/tfg-rasa:build | ||
|
||
# Run tests | ||
|
||
- name: Create test results directory | ||
run: mkdir results | ||
|
||
- name: Run data validate test | ||
run: docker run -v "$(pwd)/models:/app/models" -v "$(pwd)/results:/app/results" rauldpm/tfg-rasa:testing data-validate 2>&1 | tee -a results/output_data_validate.txt | ||
|
||
- name: Run stories test | ||
run: docker run -v "$(pwd)/models:/app/models" -v "$(pwd)/results:/app/results" rauldpm/tfg-rasa:testing test 2>&1 | tee -a results/output_stories_tests.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM rasa/rasa:3.1.1 | ||
|
||
USER root | ||
|
||
# copy proyect files | ||
# the dockerfile needs to be copied to the root path | ||
COPY . /app/ | ||
WORKDIR '/app' | ||
|
||
# train model | ||
ENTRYPOINT ["rasa", "train"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM rasa/rasa:3.1.1 | ||
|
||
USER root | ||
|
||
# copy proyect files | ||
# the dockerfile needs to be copied to the root path | ||
COPY actions/* /app/actions/ | ||
COPY data/* /app/data/ | ||
COPY tests/* /app/tests/ | ||
COPY config.yml credentials.yml domain.yml endpoints.yml /app/ | ||
COPY Docker/testing/entrypoint.sh /usr/bin/ | ||
RUN chmod +x /usr/bin/entrypoint.sh | ||
WORKDIR '/app' | ||
|
||
ENTRYPOINT ["/usr/bin/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
|
||
output=${1} | ||
|
||
|
||
actual=$(grep "Correct" ${output} | awk '{print $7}') | ||
total=$(grep "Correct" ${output} | awk '{print $9}') | ||
|
||
actual=(${actual}) | ||
total=(${total}) | ||
|
||
if [[ ${actual[0]} -ne ${total[0]} ]]; then | ||
echo "Some stories failed" | ||
exit 1 | ||
fi | ||
|
||
if [[ ${actual[1]} -ne ${total[1]} ]]; then | ||
echo "Some stories failed" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
# Adapted from https://github.com/RasaHQ/rasa-sdk/blob/main/entrypoint.sh | ||
|
||
set -Eeuo pipefail | ||
|
||
function print_help { | ||
echo "Available options:" | ||
echo " test - Run stories tests" | ||
echo " data-validate - Run nlu data validationm" | ||
} | ||
|
||
case ${1} in | ||
test) | ||
exec python -m rasa test | ||
;; | ||
data-validate) | ||
exec python -m rasa data validate | ||
;; | ||
*) | ||
print_help | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
# ChatbotTFG | ||
# ChatbotTFG | ||
|
||
[![Rasa trained model](https://github.com/rauldpm/ChatbotTFG/actions/workflows/build-model.yml/badge.svg)](https://github.com/rauldpm/ChatbotTFG/actions/workflows/build-model.yml) | ||
|
||
[![Build container builder](https://github.com/rauldpm/ChatbotTFG/actions/workflows/build-container.yml/badge.svg)](https://github.com/rauldpm/ChatbotTFG/actions/workflows/build-container.yml) | ||
|
||
[![Tests](https://github.com/rauldpm/ChatbotTFG/actions/workflows/rasa-test.yml/badge.svg)](https://github.com/rauldpm/ChatbotTFG/actions/workflows/rasa-test.yml) |