-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup ok-to-test workflow for external pull requests (#99)
* Setup ok-to-test workflow * Remove code duplication with use of composite actions
- Loading branch information
Showing
5 changed files
with
321 additions
and
85 deletions.
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,112 @@ | ||
name: E2E Tests | ||
description: Runs end to end test against Azure infrastructure | ||
inputs: | ||
e2e_config: | ||
description: 'E2E Config name' | ||
required: true | ||
registry_login_server: | ||
description: 'Image registry login server' | ||
required: true | ||
azure_credentials: | ||
description: 'Azure Credentials' | ||
required: true | ||
azure_client_id: | ||
description: 'Azure Client ID' | ||
required: true | ||
azure_client_secret: | ||
description: 'Azure Client Secret' | ||
required: true | ||
azure_storage_account_key: | ||
description: 'Azure Storage Account Key' | ||
required: true | ||
azure_tenant_id: | ||
description: 'Azure Tenant ID' | ||
required: true | ||
azure_subscription_id: | ||
description: 'Azure Subscription ID' | ||
required: true | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Setup python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.10" | ||
|
||
- name: Setup poetry | ||
shell: bash | ||
run: | | ||
python -V | ||
python -m pip install poetry | ||
- name: Build the package | ||
shell: bash | ||
run: | | ||
poetry build -f sdist | ||
- name: Initialize starter project | ||
shell: bash | ||
run: | | ||
pip install $(find "./dist" -name "*.tar.gz") | ||
kedro new --starter spaceflights --config tests/conf/${{ inputs.e2e_config }}/starter-config.yml --verbose | ||
- name: Install starter requirements | ||
shell: bash | ||
working-directory: ./spaceflights | ||
run: | | ||
find "../dist" -name "*.tar.gz" | xargs -I@ cp @ kedro-azureml.tar.gz | ||
echo -e "\n./kedro-azureml.tar.gz\n" >> src/requirements.txt | ||
echo -e "kedro-docker<0.5.0\n" >> src/requirements.txt | ||
echo -e "openpyxl\n" >> src/requirements.txt # temp fix for kedro-datasets issues with optional packages | ||
sed -i '/kedro-telemetry/d' src/requirements.txt | ||
sed -i '/kedro-viz/d' src/requirements.txt # starter version requirements make tests fail | ||
echo $(cat src/requirements.txt) | ||
pip install -r src/requirements.txt | ||
- name: Update starter configs | ||
shell: bash | ||
working-directory: ./spaceflights | ||
run: | | ||
kedro docker init | ||
sed -i 's/\(COPY src\/requirements.txt.*\)$/\1\nCOPY kedro-azureml.tar.gz ./g' Dockerfile | ||
cat Dockerfile | ||
echo "!data/01_raw" >> .dockerignore | ||
rm conf/base/catalog.yml | ||
cp ../tests/conf/${{ inputs.e2e_config }}/catalog.yml conf/base/catalog.yml | ||
cp ../tests/conf/${{ inputs.e2e_config }}/azureml.yml conf/base/azureml.yml | ||
sed -i 's/{container_registry}/${{ inputs.registry_login_server }}/g' conf/base/azureml.yml | ||
sed -i 's/{image_tag}/${{ inputs.e2e_config }}/g' conf/base/azureml.yml | ||
cat conf/base/azureml.yml | ||
- name: Login via Azure CLI | ||
uses: azure/login@v1 | ||
with: | ||
creds: ${{ inputs.azure_credentials }} | ||
|
||
- name: Login to acr.io | ||
uses: azure/docker-login@v1 | ||
with: | ||
login-server: ${{ inputs.registry_login_server }} | ||
username: ${{ inputs.azure_client_id }} | ||
password: ${{ inputs.azure_client_secret }} | ||
|
||
- name: Build and push docker image | ||
shell: bash | ||
working-directory: ./spaceflights | ||
run: | | ||
docker pull ${{ inputs.registry_login_server }}/kedro-azureml-e2e:${{ inputs.e2e_config }} || true | ||
docker build --build-arg BASE_IMAGE=python:3.10-buster -t ${{ inputs.registry_login_server }}/kedro-azureml-e2e:${{ inputs.e2e_config }} --cache-from=${{ inputs.registry_login_server }}/kedro-azureml-e2e:${{ inputs.e2e_config }} . | ||
docker push ${{ inputs.registry_login_server }}/kedro-azureml-e2e:${{ inputs.e2e_config }} | ||
- name: Run on Azure ML Pipelines | ||
shell: bash | ||
working-directory: ./spaceflights | ||
env: | ||
AZURE_STORAGE_ACCOUNT_KEY: ${{ inputs.azure_storage_account_key }} | ||
AZURE_SUBSCRIPTION_ID: ${{ inputs.azure_subscription_id }} | ||
AZURE_TENANT_ID: ${{ inputs.azure_tenant_id }} | ||
AZURE_CLIENT_SECRET: ${{ inputs.azure_client_secret }} | ||
AZURE_CLIENT_ID: ${{ inputs.azure_client_id }} | ||
run: | | ||
kedro azureml run --wait-for-completion --env-var 'GETINDATA=ROCKS!' |
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,27 @@ | ||
name: SonarCloud Scan | ||
description: Run SonarCloud scan on the codebase | ||
inputs: | ||
github_token: | ||
description: 'GitHub token' | ||
required: true | ||
sonarcloud_token: | ||
description: 'SonarCloud token' | ||
required: true | ||
project_base_dir: | ||
description: 'Project base directory' | ||
required: true | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: coverage-3.9 | ||
path: . | ||
|
||
- name: SonarCloud Scan | ||
uses: sonarsource/sonarcloud-github-action@master | ||
with: | ||
projectBaseDir: ${{ inputs.project_base_dir }} | ||
env: | ||
GITHUB_TOKEN: ${{ inputs.github_token }} | ||
SONAR_TOKEN: ${{ inputs.sonarcloud_token }} |
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,50 @@ | ||
name: Update Check Run | ||
description: Updates a check run for a specific job in a pull request | ||
inputs: | ||
github_token: | ||
description: 'GitHub token' | ||
required: true | ||
pull_request_number: | ||
description: 'Pull Request number' | ||
required: true | ||
github_job: | ||
description: 'GitHub job' | ||
required: true | ||
conclusion: | ||
description: 'Job Conclusion' | ||
required: true | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- uses: actions/github-script@v6 | ||
id: update-check-run | ||
if: ${{ always() }} | ||
env: | ||
number: ${{ inputs.pull_request_number }} | ||
job: ${{ inputs.job }} | ||
# Conveniently, job.status maps to https://developer.github.com/v3/checks/runs/#update-a-check-run | ||
conclusion: ${{ inputs.conclusion }} | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const { data: pull } = await github.rest.pulls.get({ | ||
...context.repo, | ||
pull_number: process.env.number | ||
}); | ||
const ref = pull.head.sha; | ||
const { data: checks } = await github.rest.checks.listForRef({ | ||
...context.repo, | ||
ref | ||
}); | ||
const check = checks.check_runs.filter(c => c.name === process.env.job); | ||
const { data: result } = await github.rest.checks.update({ | ||
...context.repo, | ||
check_run_id: check[0].id, | ||
status: 'completed', | ||
conclusion: process.env.conclusion | ||
}); | ||
return result; |
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,38 @@ | ||
name: Ok To Test | ||
|
||
on: | ||
issue_comment: | ||
types: [created] | ||
|
||
jobs: | ||
ok-to-test: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
pull-requests: write | ||
# Only run for PRs, not issue comments | ||
if: ${{ github.event.issue.pull_request }} | ||
steps: | ||
# Generate a GitHub App installation access token from an App ID and private key | ||
# To create a new GitHub App: | ||
# https://developer.github.com/apps/building-github-apps/creating-a-github-app/ | ||
# See app.yml for an example app manifest - you can use fake URLs when generating | ||
# the app such as example.com urls. They do not need to properly resolve for the | ||
# purpose that they app is being used for. | ||
- name: Generate token | ||
id: generate_token | ||
uses: tibdex/github-app-token@v1 | ||
with: | ||
app_id: ${{ secrets.OK_TO_TEST_APP_ID }} | ||
private_key: ${{ secrets.OK_TO_TEST_PRIVATE_KEY }} | ||
|
||
- name: Slash Command Dispatch | ||
uses: peter-evans/slash-command-dispatch@v3 | ||
env: | ||
TOKEN: ${{ steps.generate_token.outputs.token }} | ||
with: | ||
token: ${{ env.TOKEN }} # GitHub App installation access token | ||
# token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} # PAT or OAuth token will also work | ||
reaction-token: ${{ secrets.GITHUB_TOKEN }} | ||
issue-type: pull-request | ||
commands: ok-to-test | ||
permission: write |
Oops, something went wrong.