Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:heartexlabs/label-studio into fb…
Browse files Browse the repository at this point in the history
…-OPTIC-263
  • Loading branch information
Wesley Lima committed Dec 12, 2023
2 parents 489335b + 2b4d34a commit 91719ca
Show file tree
Hide file tree
Showing 73 changed files with 1,163 additions and 393 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bandit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
ref: ${{ inputs.head_sha }}

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.10'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/blue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
ref: ${{ inputs.head_sha }}

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.10'

Expand Down
22 changes: 13 additions & 9 deletions .github/workflows/build_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ on:
type: string
required: false

env:
PYTHON_VERSION_FILE: "pyproject.toml"

jobs:
pypi:
name: "PyPI"
Expand All @@ -61,23 +64,24 @@ jobs:
with:
ref: ${{ inputs.ref }}

- name: Manage version
env:
PROVIDED_VERSION: ${{ inputs.version }}
- name: Install toml
run: |
set -x
wget https://github.com/gnprice/toml-cli/releases/download/v0.2.3/toml-0.2.3-x86_64-linux.tar.gz
tar -xzf toml-0.2.3-x86_64-linux.tar.gz
set -euo pipefail
wget -q -O- "https://github.com/gnprice/toml-cli/releases/download/v0.2.3/toml-0.2.3-x86_64-linux.tar.gz" | tar -xz -C .
mv toml-0.2.3-x86_64-linux/toml toml
chmod +x toml
- name: Manage version
env:
PROVIDED_VERSION: ${{ inputs.version }}
run: |
set -euo pipefail
version=$(sed "s/^v//g" <<< ${PROVIDED_VERSION})
./toml set pyproject.toml tool.poetry.version "$version" > pyproject.toml.new
./toml set '${{ env.PYTHON_VERSION_FILE }}' tool.poetry.version "$version" > pyproject.toml.new
mv -f pyproject.toml.new pyproject.toml
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.10'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-build-ubi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
password: ${{ secrets.REDHAT_REGISTRY_PASSWORD }}

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.10'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.10'

Expand Down
101 changes: 101 additions & 0 deletions .github/workflows/docker-command.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: "/docker command"

on:
repository_dispatch:
types: [ docker-command ]

concurrency:
group: ${{ github.workflow }}-${{ github.event.client_payload.github.payload.issue.number }}-${{ github.event.client_payload.slash_command.command }}-${{ github.event.client_payload.slash_command.args.unnamed.arg1 || github.event.client_payload.slash_command.args.all }}

jobs:
create:
if: ${{ github.event.client_payload.slash_command.args.unnamed.arg1 == 'build' }}
runs-on: ubuntu-latest
timeout-minutes: 3
outputs:
error-msg: ${{ steps.check-membership.outputs.error }}
steps:
- uses: hmarr/[email protected]

- name: Check user's membership
uses: actions/github-script@v7
id: check-membership
env:
ACTOR: ${{ github.actor }}
with:
github-token: ${{ secrets.GIT_PAT }}
script: |
const { repo, owner } = context.repo;
const actor = process.env.ACTOR;
const { data: membership } = await github.rest.orgs.getMembershipForUser({
org: owner,
username: actor,
});
if (membership.state != "active") {
const error = `Unfortunately you don't have membership in ${owner} organization`;
core.setOutput("error", error);
core.setFailed(error);
}
build-docker:
name: "Build"
needs:
- create
permissions:
contents: read
checks: write
uses: ./.github/workflows/docker-build.yml
with:
sha: ${{ github.event.client_payload.pull_request.head.sha || github.event.after }}
branch_name: ${{ github.event.client_payload.pull_request.head.ref || github.ref_name }}
secrets: inherit

notification:
if: always()
needs:
- build-docker
- create
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- name: Add reaction to command comment on success
uses: peter-evans/create-or-update-comment@v3
if: needs.build-docker.result != 'failure'
with:
token: ${{ secrets.GIT_PAT }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
body: |
> Docker image was pushed with the tag `${{ needs.build-docker.outputs.image_version }}`
>
> [Workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
reactions: "+1"

- name: Add reaction to command comment on failure
uses: peter-evans/create-or-update-comment@v3
if: needs.build-docker.result == 'failure'
with:
token: ${{ secrets.GIT_PAT }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
body: |
> **Error**: failed to execute "${{ github.event.client_payload.slash_command.args.unnamed.arg1 }}" command
> [Workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
reactions: "-1"

help:
if: github.event.client_payload.slash_command.args.unnamed.arg1 == 'help'
runs-on: ubuntu-latest
timeout-minutes: 1
steps:
- name: Update comment
uses: peter-evans/create-or-update-comment@v3
with:
token: ${{ secrets.GIT_PAT }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
body: |
> Command | Description
> --- | ---
> /docker build | Build and push custom docker image
reaction-type: hooray
2 changes: 1 addition & 1 deletion .github/workflows/docker-release-promote.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ jobs:
core.setOutput("ubi-tags", ubiTags.join(','));
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.10'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/jira-command.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "/git command"
name: "/jira command"

on:
repository_dispatch:
Expand Down
38 changes: 31 additions & 7 deletions .github/workflows/release-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ jobs:
release_tag: ${{ github.ref_name }}
secrets: inherit

build_ubi_docker_image:
name: "Build UBI docker image"
uses: ./.github/workflows/docker-build-ubi.yml
with:
sha: ${{ github.ref_name }}
version: ${{ github.ref_name }}
secrets: inherit
# build_ubi_docker_image:
# name: "Build UBI docker image"
# uses: ./.github/workflows/docker-build-ubi.yml
# with:
# sha: ${{ github.ref_name }}
# version: ${{ github.ref_name }}
# secrets: inherit

build_hugging_face_docker_image:
name: "Build Hugging Face docker image"
Expand Down Expand Up @@ -125,3 +125,27 @@ jobs:
with:
docker_image_version: ${{ github.ref_name }}
secrets: inherit

notify_slack_on_failure:
name: "Notify Slack on Failure"
needs:
- promote_docker_image
- build_hugging_face_docker_image
- build-pypi
- delete-rc-assets
- update-homebrew-tap
- update-helm-chart
runs-on: ubuntu-latest
if: ${{ failure() }}
steps:
- name: Send Notification to Slack
id: slack_notify_ops_release
uses: slackapi/[email protected]
with:
channel-id: '${{ vars.SLACK_CH_RELEASE_TRAIN }}'
slack-message: |
On or more steps of Label Studio OpenSource release pipeline got failed! <!subteam^${{ vars.SLACK_GR_DEVOPS }}>
><https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|[Workflow run]>
env:
SLACK_LSE_BOT_TOKEN: ${{ secrets.SLACK_LSE_BOT_TOKEN }}
22 changes: 17 additions & 5 deletions .github/workflows/release-set-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ on:
type: string

env:
PYTHON_VERSION_FILE: "label_studio/__init__.py"
PYTHON_VERSION_FILE: "pyproject.toml"

jobs:
commit-version:
Expand Down Expand Up @@ -87,15 +87,27 @@ jobs:
exit 1
fi
- name: Install toml
run: |
set -euo pipefail
wget -q -O- "https://github.com/gnprice/toml-cli/releases/download/v0.2.3/toml-0.2.3-x86_64-linux.tar.gz" | tar -xz -C .
mv toml-0.2.3-x86_64-linux/toml toml
chmod +x toml
- name: Manage version
env:
PROVIDED_VERSION: ${{ inputs.version }}
run: |
set -euo pipefail
version=$(sed "s/^v//g" <<< ${PROVIDED_VERSION})
./toml set '${{ env.PYTHON_VERSION_FILE }}' tool.poetry.version "$version" > pyproject.toml.new
mv -f pyproject.toml.new pyproject.toml
- name: Commit version file
id: make-commit
run: |
set -euo pipefail
sed -i "s/^__version__[ ]*=.*/__version__ = '${{ inputs.version }}'/g" ${{ env.PYTHON_VERSION_FILE }}
git add ${{ env.PYTHON_VERSION_FILE }}
git commit -m "chore: Bump version to ${{ inputs.version }}" -m 'Workflow run: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
git push origin HEAD:refs/heads/${{ inputs.branch }}
2 changes: 1 addition & 1 deletion .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
ref: ${{ inputs.head_sha }}

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.10'

Expand Down
31 changes: 27 additions & 4 deletions .github/workflows/slash-command-dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ env:
ff
git
jira
docker
issue_commands_list: |
jira
jobs:
slashCommandDispatch:
Expand All @@ -24,28 +28,47 @@ jobs:
uses: actions/github-script@v7
env:
COMMANDS_LIST: ${{ env.commands_list }}
ISSUE_COMMANDS_LIST: ${{ env.issue_commands_list }}
with:
github-token: ${{ secrets.GIT_PAT }}
script: |
const body = context.payload.comment.body.toLowerCase().trim()
const commands_list = process.env.COMMANDS_LIST.split("\n")
const issue_commands_list = process.env.ISSUE_COMMANDS_LIST.split("\n")
console.log("Detected PR comment: " + body)
console.log("Commands list: " + commands_list)
console.log("Issue commands list: " + issue_commands_list)
commandArray = body.split(/\s+/)
const contextCommand = commandArray[0].split('/')[1].trim();
console.log("contextCommand: " + contextCommand)
core.setOutput('command_state', 'known')
core.setOutput('is_issue_command', 'false')
if (! commands_list.includes(contextCommand)) {
core.setOutput('command_state', 'unknown')
core.setOutput('command', contextCommand)
}
if (issue_commands_list.includes(contextCommand)) {
core.setOutput('is_issue_command', 'true')
}
- name: Slash Command Dispatch for Issues
id: scd_issues
if: ${{ steps.determine_command.outputs.command_state != 'unknown' && steps.determine_command.outputs.is_issue_command == 'true' }}
uses: peter-evans/slash-command-dispatch@v3
with:
token: ${{ secrets.GIT_PAT }}
reaction-token: ${{ secrets.GIT_PAT }}
issue-type: "issue"
reactions: true
commands: ${{ env.issue_commands_list }}

- name: Slash Command Dispatch
id: scd
if: ${{ steps.determine_command.outputs.command_state != 'unknown' }}
- name: Slash Command Dispatch for PRs
id: scd_prs
if: ${{ steps.determine_command.outputs.command_state != 'unknown' && steps.determine_command.outputs.is_issue_command != 'true' }}
uses: peter-evans/slash-command-dispatch@v3
with:
token: ${{ secrets.GIT_PAT }}
reaction-token: ${{ secrets.GIT_PAT }}
issue-type: "pull-request"
reactions: true
commands: ${{ env.commands_list }}
Expand All @@ -56,6 +79,6 @@ jobs:
with:
comment-id: ${{ github.event.comment.id }}
body: |
> '/${{ steps.determine_command.outputs.command }}' is unknown command.
> '/${{ steps.determine_command.outputs.command }}' is an unknown command.
> See '/help'
reactions: eyes, confused
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/stale@v8
- uses: actions/stale@v9
with:
days-before-issue-stale: -1
days-before-issue-close: -1 # never closed automatically
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_migrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:

- name: Set up Python
id: setup_python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.10'

Expand Down
Loading

0 comments on commit 91719ca

Please sign in to comment.