Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execute workloads based on labels instead of flags in PR titles #426

Merged
merged 1 commit into from Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
@@ -1,6 +1,6 @@
<!-- Thank you for contributing to the Akri repo! Before submitting this PR, please make sure:
1. Read the Contributing Guide before submitting your PR: https://docs.akri.sh/community/contributing
2. Decide whether you need to add any flags to your PR title, such as `[SAME VERSION]` if the version should not be changed and your change will trigger the version check workflow. This will cause the workflow to automatically succeed: https://github.com/project-akri/akri/blob/main/.github/workflows/check-versioning.yml
2. Decide whether you need to add any labels to your PR, such as `same version` if the version should not be changed and your change will trigger the version check workflow. This will cause the workflow to automatically succeed: https://github.com/project-akri/akri/blob/main/.github/workflows/check-versioning.yml
3. If this PR closes another issue, add 'closes #<issue number>' somewhere in the PR summary. GitHub will automatically close that issue when this PR gets merged. Alternatively, adding 'refs #<issue number>' will not close the issue, but help provide the reviewer more context. -->

**What this PR does / why we need it**:
Expand Down
89 changes: 73 additions & 16 deletions .github/workflows/build-opencv-base-container.yml
Expand Up @@ -10,24 +10,92 @@ on:
- build/intermediate-containers.mk
- Makefile
pull_request:
types: [opened, synchronize, reopened, labeled]
branches: [ main ]
paths:
- .github/actions/build-intermediate/**
- .github/workflows/build-opencv-base-container.yml
- build/containers/intermediate/Dockerfile.opencvsharp-build
- build/intermediate-containers.mk
- Makefile
issue_comment:
types: [created, edited]
branches: [ main ]

env:
AKRI_COMPONENT: opencvsharp-build
MAKEFILE_COMPONENT: opencv-base

jobs:

add-same-version-label-to-pr:
runs-on: ubuntu-latest
if: github.event_name == 'issue_comment' && contains(github.event.comment.body, '/add-same-version-label')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be contains or equals? Or is there no such check?

steps:
- uses: actions/checkout@v2
- name: Add same version label
uses: actions/github-script@0.9.0
if: success()
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['same version']
})
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '👋 Added [same version] label :)!'
})

add-build-label-to-pr:
runs-on: ubuntu-latest
if: github.event_name == 'issue_comment' && contains(github.event.comment.body, '/add-build-dependency-containers-label')
steps:
- uses: actions/checkout@v2
- name: Add build dependency containers label
uses: actions/github-script@0.9.0
if: success()
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['build dependency containers']
})
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '👋 Added [build dependency containers] label :)!'
})

add-label-missing-comment:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && (github.event.action == 'opened') && !contains(github.event.pull_request.labels.*.name, 'build dependency containers')
steps:
- uses: actions/checkout@v2
- name: Add comment about missing build dependency containers label
uses: actions/github-script@0.9.0
if: success()
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.createComment({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Hi there, this change should run build dependency containers, but running it will take hours. Do you want to run it? If so, please add label "build dependency containers" by commenting "/add-build-dependency-containers-label".'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kate-goldenring

Just curious, why did you choose to have a preceding backslash in "/add-build-dependency-containers-label"
I use preceding "/" to differentiate between generic comments and commands. Thought I don't have a strong reference here. Any suggestion?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems fine to me

})

per-arch:
if: >-
!contains(github.event.pull_request.title, '[IGNORE INTERMEDIATE BUILDS]') &&
!contains(github.event.commits[0].message, '[IGNORE INTERMEDIATE BUILDS]')
if: contains(github.event.pull_request.labels.*.name, 'build dependency containers')
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -41,21 +109,10 @@ jobs:
with:
persist-credentials: false

- name: Akri intermediate builds are LONG running and should only be run when absolutely needed
if: >-
!contains(github.event.pull_request.title, '[ALLOW INTERMEDIATE BUILDS]') &&
!contains(github.event.commits[0].message, '[ALLOW INTERMEDIATE BUILDS]')
run: |
echo "Akri intermediate builds are LONG running and should only be run when absolutely needed."
echo "Add [IGNORE INTERMEDIATE BUILDS] to first commit message to skip building intermediate containers."
echo "Add [ALLOW INTERMEDIATE BUILDS] to first commit message if needed."
exit 1

# Only run build version change check if PR title and Merge commit message do NOT contain "[SAME VERSION]"
# Only run build version change check if PR does not have "same version" label
- if: >-
startsWith(github.event_name, 'pull_request') &&
!contains(github.event.pull_request.title, '[SAME VERSION]') &&
!contains(github.event.commits[0].message, '[SAME VERSION]')
!contains(github.event.pull_request.labels.*.name, 'same version')
name: Ensure that ${{ env.AKRI_COMPONENT }} version has changed
run: |
git fetch origin main
Expand Down
89 changes: 73 additions & 16 deletions .github/workflows/build-rust-crossbuild-container.yml
Expand Up @@ -10,24 +10,92 @@ on:
- build/intermediate-containers.mk
- Makefile
pull_request:
types: [opened, synchronize, reopened, labeled]
branches: [ main ]
paths:
- .github/actions/build-intermediate/**
- .github/workflows/build-rust-crossbuild-container.yml
- build/containers/intermediate/Dockerfile.rust-crossbuild-*
- build/intermediate-containers.mk
- Makefile
issue_comment:
types: [created, edited]
branches: [ main ]

env:
AKRI_COMPONENT: rust-crossbuild
MAKEFILE_COMPONENT: rust-crossbuild

jobs:

add-same-version-label-to-pr:
runs-on: ubuntu-latest
if: github.event_name == 'issue_comment' && contains(github.event.comment.body, '/add-same-version-label')
steps:
- uses: actions/checkout@v2
- name: Add same version label
uses: actions/github-script@0.9.0
if: success()
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['same version']
})
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '👋 Added [same version] label :)!'
})

add-build-label-to-pr:
runs-on: ubuntu-latest
if: github.event_name == 'issue_comment' && contains(github.event.comment.body, '/add-build-dependency-containers-label')
steps:
- uses: actions/checkout@v2
- name: Add build dependency containers label
uses: actions/github-script@0.9.0
if: success()
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['build dependency containers']
})
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '👋 Added [build dependency containers] label :)!'
})

add-label-missing-comment:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && (github.event.action == 'opened') && !contains(github.event.pull_request.labels.*.name, 'build dependency containers')
steps:
- uses: actions/checkout@v2
- name: Add comment about missing build dependency containers label
uses: actions/github-script@0.9.0
if: success()
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.createComment({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Hi there, this change should run build dependency containers, but running it will take hours. Do you want to run it? If so, please add label "build dependency containers" by commenting "/add-build-dependency-containers-label".'
})

per-arch:
if: >-
!contains(github.event.pull_request.title, '[IGNORE INTERMEDIATE BUILDS]') &&
!contains(github.event.commits[0].message, '[IGNORE INTERMEDIATE BUILDS]')
if: contains(github.event.pull_request.labels.*.name, 'build dependency containers')
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -41,21 +109,10 @@ jobs:
with:
persist-credentials: false

- name: Akri intermediate builds are LONG running and should only be run when absolutely needed
if: >-
!contains(github.event.pull_request.title, '[ALLOW INTERMEDIATE BUILDS]') &&
!contains(github.event.commits[0].message, '[ALLOW INTERMEDIATE BUILDS]')
run: |
echo "Akri intermediate builds are LONG running and should only be run when absolutely needed."
echo "Add [IGNORE INTERMEDIATE BUILDS] to first commit message to skip building intermediate containers."
echo "Add [ALLOW INTERMEDIATE BUILDS] to first commit message if needed."
exit 1

# Only run build version change check if PR title and Merge commit message do NOT contain "[SAME VERSION]"
# Only run build version change check if PR does not have "same version" label
- if: >-
startsWith(github.event_name, 'pull_request') &&
!contains(github.event.pull_request.title, '[SAME VERSION]') &&
!contains(github.event.commits[0].message, '[SAME VERSION]')
!contains(github.event.pull_request.labels.*.name, 'same version')
name: Ensure that ${{ env.AKRI_COMPONENT }} version has changed
run: |
git fetch origin main
Expand Down
18 changes: 11 additions & 7 deletions .github/workflows/check-versioning.yml
Expand Up @@ -20,6 +20,7 @@ on:
- scripts/**
- tests/**
pull_request:
types: [assigned, opened, synchronize, reopened, labeled, unlabeled]
branches: [ main ]
paths-ignore:
- '.gitignore'
Expand All @@ -40,6 +41,9 @@ on:
release:
types:
- published
issues:
types:
- labeled

env:
CARGO_TERM_COLOR: always
Expand All @@ -54,14 +58,14 @@ jobs:
uses: actions/checkout@v2
with:
persist-credentials: false
# Only run version check for PRs. If PR title does NOT contain "[SAME VERSION]", then ensure that

# Only run version check for PRs. If PR does NOT have "same version" label, then ensure that
# version.txt is different from what is in main.
- if: startsWith(github.event_name, 'pull_request') && contains(github.event.pull_request.title, '[SAME VERSION]') == false
name: Run version check
- if: startsWith(github.event_name, 'pull_request') && !contains(github.event.pull_request.labels.*.name, 'same version')
name: Run version check (triggered by "same version" label)
run: ./version.sh -c
# If PR title does contain "[SAME VERSION]", then do not check that version.txt is different from
# If PR does have "same version" label, then do not check that version.txt is different from
# what is in main.
- if: startsWith(github.event_name, 'pull_request') && contains(github.event.pull_request.title, '[SAME VERSION]') == true
name: Run version check
- if: startsWith(github.event_name, 'pull_request') && contains(github.event.pull_request.labels.*.name, 'same version')
name: Run version check (skip, triggered by "same version" label)
run: ./version.sh -c -s