Added OCI Authorizer Function #31
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
name: Run Tests | |
on: | |
pull_request: | |
paths: | |
- "container-image/**" | |
- "oci_mlflow/**" | |
- "tests/**" | |
- "**requirements.txt" | |
- pyproject.toml | |
# To run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# Cancel in progress workflows on pull_requests. | |
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
permissions: | |
contents: read | |
pull-requests: write | |
# hack for https://github.com/actions/cache/issues/810#issuecomment-1222550359 | |
env: | |
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 5 | |
jobs: | |
test: | |
name: python ${{ matrix.python-version }} | |
runs-on: ubuntu-latest | |
timeout-minutes: 20 | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ["3.8", "3.9", "3.10"] | |
include: | |
- python-version: "3.9" | |
cov-reports: --cov=oci_mlflow --cov-report=xml --cov-report=html | |
steps: | |
- uses: actions/checkout@v3 | |
# Caching python libraries installed with pip | |
# https://github.com/actions/cache/blob/main/examples.md#python---pip | |
- uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/test-requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: "Test config setup" | |
shell: bash | |
env: | |
HOME_RUNNER_DIR: /home/runner | |
run: | | |
set -x # print commands that are executed | |
mkdir -p "$HOME_RUNNER_DIR"/.oci | |
openssl genrsa -out $HOME_RUNNER_DIR/.oci/oci_mlflow_user.pem 2048 | |
cat <<EOT >> "$HOME_RUNNER_DIR/.oci/config" | |
[DEFAULT] | |
user=ocid1.user.oc1..xxx | |
fingerprint=00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 | |
tenancy=ocid1.tenancy.oc1..xxx | |
region=test_region | |
key_file=$HOME_RUNNER_DIR/.oci/oci_mlflow_user.pem | |
EOT | |
ls -lha "$HOME_RUNNER_DIR"/.oci | |
echo "Test config file:" | |
cat $HOME_RUNNER_DIR/.oci/config | |
- name: "Run tests" | |
timeout-minutes: 5 | |
shell: bash | |
run: | | |
set -x # print commands that are executed | |
$CONDA/bin/conda init | |
source /home/runner/.bashrc | |
pip install -r test-requirements.txt | |
python -m pytest ${{ matrix.cov-reports }} tests | |
- name: "Calculate coverage" | |
if: ${{ success() }} && ${{ github.event.issue.pull_request }} | |
run: | | |
set -x # print commands that are executed | |
# Prepare default cov body text | |
COV_BODY_INTRO="📌 Overall coverage:\n\n" | |
echo COV_BODY="$COV_BODY_INTRO No success to gather report. 😿" >> $GITHUB_ENV | |
# Calculate overall coverage and update body message | |
COV=$(grep -E 'pc_cov' htmlcov/index.html | cut -d'>' -f 2 | cut -d'%' -f 1) | |
if [[ ! -z $COV ]]; then | |
ROUNDED_COV=$(echo $COV | cut -d'.' -f 1) | |
if [[ $ROUNDED_COV -lt 50 ]]; then COLOR=red; elif [[ $ROUNDED_COV -lt 80 ]]; then COLOR=yellow; else COLOR=green; fi | |
echo COV_BODY="$COV_BODY_INTRO ![Coverage-$COV%](https://img.shields.io/badge/coverage-$COV%25-$COLOR)" >> $GITHUB_ENV | |
fi | |
- name: "Add comment with coverage info to PR" | |
uses: actions/github-script@v6 | |
if: ${{ success() }} && ${{ github.event.issue.pull_request }} | |
with: | |
github-token: ${{ github.token }} | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: '${{ env.COV_BODY }}' | |
}) | |
- name: "Save coverage files" | |
uses: actions/upload-artifact@v3 | |
if: ${{ matrix.cov-reports }} | |
with: | |
name: cov-reports | |
path: | | |
htmlcov/ | |
.coverage | |
coverage.xml |