Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

[CI] Move check_labels to github actions #2415

Merged
7 commits merged into from
Feb 10, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/check-labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Check labels

on:
pull_request:
types: [opened, synchronize, labeled]

jobs:
check-labels:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Check labels
run: bash ${{ github.workspace }}/scripts/github/check_labels.sh
env:
GITHUB_PR: ${{ github.event.pull_request.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12 changes: 9 additions & 3 deletions scripts/gitlab/lib.sh → scripts/common/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,17 @@ has_label(){
repo="$1"
pr_id="$2"
label="$3"

# These will exist if the function is called in Gitlab.
# If the function's called in Github, we should have GITHUB_ACCESS_TOKEN set
# already.
if [ -n "$GITHUB_RELEASE_TOKEN" ]; then
out=$(curl -H "Authorization: token $GITHUB_RELEASE_TOKEN" -s "$api_base/$repo/pulls/$pr_id")
else
out=$(curl -H "Authorization: token $GITHUB_PR_TOKEN" -s "$api_base/$repo/pulls/$pr_id")
GITHUB_TOKEN="$GITHUB_RELEASE_TOKEN"
elif [ -n "$GITHUB_PR_TOKEN" ]; then
GITHUB_TOKEN="$GITHUB_PR_TOKEN"
fi

out=$(curl -H "Authorization: token $GITHUB_TOKEN" -s "$api_base/$repo/pulls/$pr_id")
[ -n "$(echo "$out" | tr -d '\r\n' | jq ".labels | .[] | select(.name==\"$label\")")" ]
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#!/usr/bin/env bash

#shellcheck source=lib.sh
source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/lib.sh"
#shellcheck source=../common/lib.sh
source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/../common/lib.sh"

repo='paritytech/polkadot'
repo="$GITHUB_REPOSITORY"
pr="$GITHUB_PR"

ensure_labels() {
for label in "$@"; do
if has_label "$repo" "$CI_COMMIT_BRANCH" "$label"; then
if has_label "$repo" "$pr" "$label"; then
return 0
fi
done
Expand Down
4 changes: 2 additions & 2 deletions scripts/gitlab/check_runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
set -e # fail on any error

#Include the common functions library
#shellcheck source=lib.sh
. "$(dirname "${0}")/lib.sh"
#shellcheck source=../common/lib.sh
. "$(dirname "${0}")/../common/lib.sh"

SUBSTRATE_REPO="https://github.com/paritytech/substrate"
SUBSTRATE_REPO_CARGO="git\+${SUBSTRATE_REPO}"
Expand Down
4 changes: 2 additions & 2 deletions scripts/gitlab/check_runtime_benchmarks.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

#shellcheck source=lib.sh
source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/lib.sh"
#shellcheck source=../common/lib.sh
source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/../common/lib.sh"

time cargo check --features runtime-benchmarks
4 changes: 2 additions & 2 deletions scripts/gitlab/check_web_wasm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

#shellcheck source=lib.sh
source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/lib.sh"
#shellcheck source=../common/lib.sh
source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/../common/lib.sh"

time cargo build --locked --target=wasm32-unknown-unknown --manifest-path cli/Cargo.toml --no-default-features --features browser
4 changes: 2 additions & 2 deletions scripts/gitlab/test_deterministic_wasm.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

#shellcheck source=lib.sh
source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/lib.sh"
#shellcheck source=../common/lib.sh
source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/../common/lib.sh"

# build runtime
WASM_BUILD_NO_COLOR=1 cargo build --verbose --release -p kusama-runtime -p polkadot-runtime -p westend-runtime
Expand Down
4 changes: 2 additions & 2 deletions scripts/gitlab/test_linux_stable.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env bash
set -e

#shellcheck source=lib.sh
source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/lib.sh"
#shellcheck source=../common/lib.sh
source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/../common/lib.sh"

time cargo test --all --release --verbose --locked --features=runtime-benchmarks --features=real-overseer

Expand Down