forked from eclipse-che/che
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(repositories): Add yaml with all repositories used in Eclipse Che
And add a script to update CONTRIBUTING.md and a github action to check if CONTRIBUTING.md need to be updated or not Change-Id: Idf551383bb806e11308d1e157af2f2921c593cd3 Signed-off-by: Florent Benoit <fbenoit@redhat.com>
- Loading branch information
Showing
4 changed files
with
488 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# | ||
# Copyright (c) 2020 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 | ||
# | ||
|
||
# Eclipse Che workflow for checking repository list in CONTRIBUTING.md file | ||
name: CI | ||
|
||
# Trigger the workflow on push or pull request | ||
on: | ||
push: | ||
paths: | ||
- '.repositories.yaml' | ||
pull_request: | ||
paths: | ||
- '.repositories.yaml' | ||
jobs: | ||
check-contributing-up-to-date: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
name: Checkout che-theia source code | ||
- name: check | ||
run: | | ||
./.repositories-update-contributing.sh check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
#!/bin/sh | ||
# Copyright (c) 2020 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 | ||
# | ||
# ./.repositories-update-contributing.sh | ||
# no parameter = execute it with docker command | ||
# ./.repositories-update-contributing.sh -w | ||
# execute in native mode (need to have mikefarah/yq installed ) | ||
|
||
set -e | ||
set -u | ||
|
||
YQ_IMAGE="mikefarah/yq:3.3.2" | ||
|
||
DIR=$(cd "$(dirname "$0")"; pwd) | ||
|
||
init() { | ||
GREEN='\033[0;32m' | ||
RED='\033[0;31m' | ||
NC='\033[0m' | ||
BOLD='\033[1m' | ||
} | ||
|
||
LAUNCH_IN_DOCKER=true | ||
CHECK_MODE=false | ||
analyze_args() { | ||
if [ $# -eq 0 ]; then | ||
return | ||
fi | ||
if [ "$1" = "IN_DOCKER" ] || [ "$1" = "-w" ]; then | ||
LAUNCH_IN_DOCKER=false | ||
shift | ||
fi | ||
if [ $# -eq 0 ]; then | ||
return | ||
fi | ||
if [ "$1" = "check" ] ; then | ||
CHECK_MODE=true | ||
fi | ||
} | ||
|
||
markdown_link() { | ||
name=$1 | ||
url=$2 | ||
if [ "${url}" != "" ]; then | ||
echo "[${name}](${url})" | ||
else | ||
echo "" | ||
fi | ||
} | ||
|
||
compute() { | ||
repo_names=$(yq r .repositories.yaml "repositories.*.name") | ||
echo "Repository | Component | Description | Devfile | Documentation" | ||
echo "--- | --- | --- | --- | ---" | ||
for repo_name in ${repo_names}; do | ||
url=$(yq r .repositories.yaml "repositories.name==${repo_name}.url") | ||
description=$(yq r .repositories.yaml "repositories.name==${repo_name}.description") | ||
devfile=$(yq r .repositories.yaml "repositories.name==${repo_name}.devfile") | ||
doc=$(yq r .repositories.yaml "repositories.name==${repo_name}.doc") | ||
echo "$(markdown_link "${repo_name}" "${url}") | | ${description} | $(markdown_link "devfile" "${devfile}") | $(markdown_link "doc" "${doc}")" | ||
# components ? | ||
components_names=$(yq r .repositories.yaml "repositories.(name==${repo_name}).components.*.name") | ||
for component_name in ${components_names}; do | ||
component_url=$(yq r .repositories.yaml "repositories.(name==${repo_name}).components.(name==${component_name}).url") | ||
component_description=$(yq r .repositories.yaml "repositories.(name==${repo_name}).components.(name==${component_name}).description") | ||
echo "---| $(markdown_link "${component_name}" "${component_url}") | ${component_description} | | |" | ||
done | ||
done | ||
} | ||
|
||
update_contributing() { | ||
CONTRIBUTING_FILE=${DIR}/CONTRIBUTING.md | ||
TARGET_FILE=${DIR}/CONTRIBUTING.md | ||
|
||
if [ ${CHECK_MODE} = true ]; then | ||
TARGET_FILE=${DIR}/target/CONTRIBUTING.md | ||
fi | ||
|
||
|
||
content_to_include=$(compute) | ||
|
||
# get begin/end lines | ||
begin_line=$(grep -n '<!-- begin repository list -->' "${CONTRIBUTING_FILE}" | cut -d ":" -f 1 | head -n 1) | ||
end_line=$(grep -n '<!-- end repository list -->' "${CONTRIBUTING_FILE}" | cut -d ":" -f 1 | head -n 1) | ||
|
||
# update content | ||
mkdir -p "${DIR}/target" | ||
cp "${CONTRIBUTING_FILE}" "${DIR}/target/contributing.original" | ||
(head -n "${begin_line}" "${CONTRIBUTING_FILE}" && echo "${content_to_include}" && tail -n "+${end_line}" "${CONTRIBUTING_FILE}") > "${DIR}/.tmp-contributing" | ||
mv "${DIR}/.tmp-contributing" "${TARGET_FILE}" | ||
} | ||
|
||
run_in_docker() { | ||
printf "%bRunning%b $*\n" "${BOLD}" "${NC}" | ||
GIT_ROOT_DIRECTORY=$(git rev-parse --show-toplevel) | ||
if docker run --rm -v "${GIT_ROOT_DIRECTORY}":/workdir --entrypoint=/bin/sh "${YQ_IMAGE}" "/workdir/$0" "IN_DOCKER" "$@" | ||
then | ||
printf "Script execution %b[OK]%b\n" "${GREEN}" "${NC}" | ||
else | ||
printf "%bFail to run the script%b\n" "${RED}" "${NC}" | ||
exit 1 | ||
fi | ||
} | ||
|
||
init "$@" | ||
analyze_args "$@" | ||
if [ ${LAUNCH_IN_DOCKER} = true ]; then | ||
run_in_docker "$@" | ||
else | ||
update_contributing | ||
fi | ||
|
||
if [ ${CHECK_MODE} = true ]; then | ||
if ! diff "${DIR}/target/contributing.original" "${DIR}/target/CONTRIBUTING.md"; then | ||
printf "%bError: %bCONTRIBUTING.md should be updated as repositories.yaml file has been updated\n" "${RED}" "${NC}" | ||
printf "%s" "Run the command: ./.repositories-update-contributing.sh" | ||
exit 1 | ||
fi | ||
|
||
fi |
Oops, something went wrong.