Skip to content

Commit e6c546b

Browse files
authored
Merge pull request #2 from Bobbins228/test-sync-workflow
Test sync workflow
2 parents 415b055 + a1d95fc commit e6c546b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+8947
-12722
lines changed

.github/build/Containerfile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,18 @@ LABEL summary="Toolchain for running pre-commit hooks." \
55
io.k8s.display-name="Pre-Commit Toolchain"
66

77
USER root
8-
RUN dnf install nodejs
8+
RUN dnf install nodejs -y && \
9+
dnf clean all && \
10+
rm -rf /var/cache/dnf
11+
ADD https://mirror.openshift.com/pub/openshift-v4/clients/oc/latest/linux/oc.tar.gz $TMPDIR/
12+
RUN tar -C /usr/local/bin -xvf $TMPDIR/oc.tar.gz && \
13+
chmod +x /usr/local/bin/oc && \
14+
rm $TMPDIR/oc.tar.gz
915
USER $USERID
1016

11-
COPY requirements-dev.txt /tmp/requirements-dev.txt
12-
RUN python -m pip install -r /tmp/requirements-dev.txt
17+
RUN pip3 install poetry && \
18+
poetry config virtualenvs.create false
19+
COPY pyproject.toml ./
20+
RUN poetry install
1321

1422
CMD bash

.github/build/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# Pre-Commit Build Artifacts
22

3-
This directory contains the artifacts required to build the codeflare-sdk pre-commit image. As of right now, we will need to manually update `requirements-dev.txt` in this directory as well.
3+
This directory contains the artifacts required to build the codeflare-sdk pre-commit image.
4+
5+
To build the image run `podman build -f .github/build/Containerfile .` from the root directory.

.github/build/requirements-dev.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Label new issues as needs-triage and add to CodeFlare Sprint Board
2+
on:
3+
issues:
4+
types:
5+
- opened
6+
jobs:
7+
add_label:
8+
name: Add needs-triage label to new issues
9+
runs-on: ubuntu-latest
10+
permissions:
11+
issues: write
12+
steps:
13+
- uses: actions/checkout@v3
14+
- run: gh issue edit ${{ github.event.issue.number }} --add-label "triage/needs-triage"
15+
env:
16+
GH_TOKEN: ${{ github.token }}
17+
18+
add-to-project:
19+
name: Add issue to project
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/[email protected]
23+
with:
24+
project-url: https://github.com/orgs/project-codeflare/projects/8
25+
github-token: ${{ secrets.CODEFLARE_MACHINE_ACCOUNT_TOKEN }}

.github/workflows/coverage-badge.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ jobs:
2020
- name: Install dependencies
2121
run: |
2222
python -m pip install --upgrade pip
23-
pip install pytest==6.2.4
24-
pip install pytest-mock==3.6.1
25-
pip install coverage
26-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
23+
pip install poetry
24+
poetry config virtualenvs.create false
25+
poetry lock --no-update
26+
poetry install --with test
2727
- name: Generate coverage report
2828
run: |
2929
coverage run -m --source=src pytest -v tests/unit_test.py

.github/workflows/fork-sync.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# This workflow will build the CodeFlare Operator image and push it to the opendatahub image registry as well as update versions in the MakeFile and README
2+
3+
name: Fork Sync
4+
5+
on:
6+
workflow_dispatch:
7+
8+
jobs:
9+
sync:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v3
14+
- uses: tgymnich/[email protected]
15+
with:
16+
token: ${{ secrets.CODEFLARE_MACHINE_ACCOUNT_TOKEN }}
17+
base: main
18+
head: main
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Notebook Image Build and Push
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release-version:
7+
type: string
8+
required: true
9+
description: 'Version number (for example: 0.1.0)'
10+
is-stable:
11+
description: 'Select if the built image should be tagged as stable'
12+
required: true
13+
type: boolean
14+
quay-organization:
15+
description: 'Quay organization used to push the built images to'
16+
required: true
17+
default: 'project-codeflare'
18+
python_version:
19+
type: string
20+
default: "3.8"
21+
required: true
22+
poetry_version:
23+
type: string
24+
default: "1.5.1"
25+
required: true
26+
27+
jobs:
28+
release:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Cleanup
32+
run: |
33+
ls -lart
34+
echo "Initial status:"
35+
df -h
36+
echo "Cleaning up resources:"
37+
sudo swapoff -a
38+
sudo rm -f /swapfile
39+
sudo apt clean
40+
sudo rm -rf /usr/share/dotnet
41+
sudo rm -rf /opt/ghc
42+
sudo rm -rf "/usr/local/share/boost"
43+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
44+
docker rmi $(docker image ls -aq)
45+
echo "Final status:"
46+
df -h
47+
- name: Checkout the repository
48+
uses: actions/checkout@v3
49+
- name: Install Python
50+
uses: actions/setup-python@v4
51+
with:
52+
python-version: ${{ github.event.inputs.python_version }}
53+
- name: Image Build
54+
run: |
55+
cd custom-nb-image
56+
podman build --build-arg SDK_VERSION="${{ github.event.inputs.release-version }}" -t quay.io/${{ github.event.inputs.quay-organization }}/notebook:v${{ github.event.inputs.release-version }} .
57+
- name: Login to Quay.io
58+
uses: redhat-actions/podman-login@v1
59+
with:
60+
registry: quay.io
61+
username: ${{ secrets.QUAY_ID }}
62+
password: ${{ secrets.QUAY_TOKEN }}
63+
- name: Image Push
64+
run: podman push quay.io/${{ github.event.inputs.quay-organization }}/notebook:v${{ github.event.inputs.release-version }}
65+
- name: Image Push Stable
66+
if: ${{ inputs.is-stable }}
67+
run: podman push quay.io/${{ github.event.inputs.quay-organization }}/notebook:v${{ github.event.inputs.release-version }} quay.io/${{ github.event.inputs.quay-organization }}/notebook:stable
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Nightly Image Build
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
9+
env:
10+
PYTHON_VERSION: 3.8
11+
POETRY_VERSION: 1.5.1
12+
QUAY_ORGANIZATION: 'project-codeflare'
13+
SDK_FILE: 'codeflare_sdk-0.0.0.dev0.tar.gz'
14+
IMAGE_TAG: 'dev'
15+
16+
jobs:
17+
nightly-build:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout the repository
21+
uses: actions/checkout@v3
22+
- name: Install Python
23+
uses: actions/setup-python@v4
24+
with:
25+
python-version: ${{ env.PYTHON_VERSION }}
26+
- name: Install Poetry
27+
uses: abatilo/actions-poetry@v2
28+
with:
29+
poetry-version: ${{ env.POETRY_VERSION }}
30+
- name: Run poetry install
31+
run: poetry install --with docs
32+
- name: Run poetry build
33+
run: poetry build
34+
- name: Copy SDK package
35+
run: cp dist/${SDK_FILE} custom-nb-image
36+
- name: Modify Dockerfile to use locally built SDK
37+
run: |
38+
sed -i "s/ARG SDK_VERSION=.*/COPY ${{ env.SDK_FILE }} ./" custom-nb-image/Dockerfile
39+
sed -i "s/codeflare-sdk==.*/${{ env.SDK_FILE }}\\\\/" custom-nb-image/Dockerfile
40+
- name: Image Build
41+
working-directory: custom-nb-image
42+
run: docker build -t quay.io/${{ env.QUAY_ORGANIZATION }}/notebook:${{ env.IMAGE_TAG }} .
43+
- name: Login to Quay.io
44+
uses: docker/login-action@v2
45+
with:
46+
registry: quay.io
47+
username: ${{ secrets.QUAY_ID }}
48+
password: ${{ secrets.QUAY_TOKEN }}
49+
- name: Image Push
50+
run: docker push quay.io/${{ env.QUAY_ORGANIZATION }}/notebook:${{ env.IMAGE_TAG }}
File renamed without changes.

.github/workflows/python-app.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

.github/workflows/release.yaml

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ on:
77
type: string
88
required: true
99
description: 'Version number (for example: 0.1.0)'
10-
is-latest:
11-
description: 'Select if the built image should be tagged as latest'
10+
is-stable:
11+
description: 'Select if the built image should be tagged as stable'
1212
required: true
1313
type: boolean
1414
quay-organization:
@@ -23,12 +23,18 @@ on:
2323
type: string
2424
default: "1.5.1"
2525
required: true
26+
codeflare-repository-organization:
27+
type: string
28+
default: "project-codeflare"
2629

2730
jobs:
2831
release:
2932
runs-on: ubuntu-latest
3033
permissions:
3134
contents: write
35+
id-token: write # This permission is required for trusted publishing
36+
env:
37+
PR_BRANCH_NAME: adjustments-release-${{ github.event.inputs.release-version }}
3238
steps:
3339
- name: Checkout the repository
3440
uses: actions/checkout@v3
@@ -48,34 +54,49 @@ jobs:
4854
run: poetry build
4955
- name: Create new documentation
5056
run: poetry run pdoc --html -o docs src/codeflare_sdk && pushd docs && rm -rf cluster job utils && mv codeflare_sdk/* . && rm -rf codeflare_sdk && popd && find docs -type f -name "*.html" -exec bash -c "echo '' >> {}" \;
51-
- name: Set Pypi token
52-
run: poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}
53-
- name: Publish new release to Pypi repository
54-
run: poetry publish
5557

5658
- name: Commit changes in docs
5759
uses: stefanzweifel/git-auto-commit-action@v4
5860
with:
5961
file_pattern: 'docs'
6062
commit_message: "Changes in docs for release: v${{ github.event.inputs.release-version }}"
63+
create_branch: true
64+
branch: ${{ env.PR_BRANCH_NAME }}
65+
- name: Create a PR with code changes
66+
run: |
67+
if git branch -a | grep "${{ env.PR_BRANCH_NAME }}"; then
68+
GIT_BRANCH=${GITHUB_REF#refs/heads/}
69+
gh pr create --base "$GIT_BRANCH" --fill --head "${{ env.PR_BRANCH_NAME }}" --label "lgtm" --label "approved"
70+
fi
71+
env:
72+
GITHUB_TOKEN: ${{ secrets.CODEFLARE_MACHINE_ACCOUNT_TOKEN }}
73+
- name: Wait until PR with code changes is merged
74+
run: |
75+
if git branch -a | grep "${{ env.PR_BRANCH_NAME }}"; then
76+
timeout 3600 bash -c 'until [[ $(gh pr view '${{ env.PR_BRANCH_NAME }}' --json state --jq .state) == "MERGED" ]]; do sleep 5 && echo "$(gh pr view '${{ env.PR_BRANCH_NAME }}' --json state --jq .state)"; done'
77+
fi
78+
env:
79+
GITHUB_TOKEN: ${{ github.TOKEN }}
6180
- name: Create Github release
6281
uses: ncipollo/release-action@v1
6382
with:
6483
tag: "v${{ github.event.inputs.release-version }}"
84+
- name: Publish package distributions to PyPI
85+
uses: pypa/gh-action-pypi-publish@release/v1
6586

66-
- name: Image Build
87+
- name: Notebook Image Build and Push
6788
run: |
68-
cd custom-nb-image
69-
docker build --build-arg SDK_VERSION="${{ github.event.inputs.release-version }}" -t quay.io/${{ github.event.inputs.quay-organization }}/notebook:v${{ github.event.inputs.release-version }} .
70-
docker tag quay.io/${{ github.event.inputs.quay-organization }}/notebook:v${{ github.event.inputs.release-version }} quay.io/${{ github.event.inputs.quay-organization }}/notebook:latest
71-
- name: Login to Quay.io
72-
uses: docker/login-action@v2
73-
with:
74-
registry: quay.io
75-
username: ${{ secrets.QUAY_ID }}
76-
password: ${{ secrets.QUAY_TOKEN }}
77-
- name: Image Push
78-
run: docker push quay.io/${{ github.event.inputs.quay-organization }}/notebook:v${{ github.event.inputs.release-version }}
79-
- name: Image Push Latest
80-
if: ${{ inputs.is-latest }}
81-
run: docker push quay.io/${{ github.event.inputs.quay-organization }}/notebook:latest
89+
gh workflow run image-build-and-push.yaml --repo ${{ github.event.inputs.codeflare-repository-organization }}/codeflare-sdk --ref ${{ github.ref }} --field is-stable=${{ github.event.inputs.is-stable }} --field release-version=${{ github.event.inputs.release-version }} --field quay-organization=${{ github.event.inputs.quay-organization }}
90+
env:
91+
GITHUB_TOKEN: ${{ secrets.CODEFLARE_MACHINE_ACCOUNT_TOKEN }}
92+
shell: bash
93+
94+
- name: Wait for Notebook image build and push to finish
95+
run: |
96+
# wait for a while for Run to be started
97+
sleep 5
98+
run_id=$(gh run list --workflow image-build-and-push.yaml --repo ${{ github.event.inputs.codeflare-repository-organization }}/codeflare-sdk --limit 1 --json databaseId --jq .[].databaseId)
99+
gh run watch ${run_id} --repo ${{ github.event.inputs.codeflare-repository-organization }}/codeflare-sdk --interval 10 --exit-status
100+
env:
101+
GITHUB_TOKEN: ${{ secrets.CODEFLARE_MACHINE_ACCOUNT_TOKEN }}
102+
shell: bash

.github/workflows/unit-tests.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Python Tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
unit-tests:
11+
12+
runs-on: ubuntu-latest
13+
container:
14+
image: quay.io/project-codeflare/codeflare-sdk-precommit:v0.0.3
15+
steps:
16+
- uses: actions/checkout@v3
17+
- name: Install poetry
18+
run: pip install poetry
19+
- uses: actions/setup-python@v4
20+
with:
21+
python-version: '3.8'
22+
- name: Install dependencies
23+
run: |
24+
poetry config virtualenvs.create false
25+
poetry lock --no-update
26+
poetry install --with test
27+
- name: Test with pytest and check coverage
28+
run: |
29+
coverage run -m --source=src pytest -v tests/unit_test.py
30+
coverage=$(coverage report -m | tail -1 | tail -c 4 | head -c 2)
31+
if (( $coverage < 90 )); then exit 1; else echo "Coverage passed, ${coverage}%"; fi

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ __pycache__/
44
.coverage
55
Pipfile
66
Pipfile.lock
7-
poetry.lock
87
.venv*
98
build/
109
tls-cluster-namespace

0 commit comments

Comments
 (0)