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

Add a PR check to ensure that sidecar executable files have executable permissions #824

Merged
merged 1 commit into from
Feb 2, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .ci/sidecar-check-script-permissions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
#
# Copyright (c) 2021 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#

set -e

# shellcheck disable=SC2207
FILES_CHANGED=($(git diff --name-only -r "$1" "$2" -- "sidecars/*.sh"))
NON_EXECUTABLE_SCRIPTS=()

for file in "${FILES_CHANGED[@]}"
do
if ! [[ -x "$file" ]]; then
echo "ERROR: $file is not executable"
NON_EXECUTABLE_SCRIPTS+=("$file")
fi
done

# shellcheck disable=SC2199
if [[ "${NON_EXECUTABLE_SCRIPTS[@]}" ]]; then
exit 1
fi
30 changes: 30 additions & 0 deletions .github/workflows/sidecar-scripts-executable-pr-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#
# Copyright (c) 2021 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#

name: Sidecar scripts PR check

on:
pull_request:
paths:
- 'sidecars/**'

jobs:
executable-permissions-pr-check:
runs-on: ubuntu-20.04

steps:
- name: Clone source code
uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: Check .sh files inside sidecars folder
run: |
./.ci/sidecar-check-script-permissions.sh origin/${{ github.base_ref }} ${{ github.event.pull_request.head.sha }}