-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #245 from jstourac/ciChecks
Introduces basic JSON and YAML checks into this repository
- Loading branch information
Showing
41 changed files
with
622 additions
and
498 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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
name: Auto Add Issues to Tracking boards | ||
on: | ||
on: # yamllint disable-line rule:truthy | ||
issues: | ||
types: | ||
- opened | ||
|
@@ -21,4 +22,4 @@ jobs: | |
- uses: actions/[email protected] | ||
with: | ||
project-url: https://github.com/orgs/opendatahub-io/projects/45 | ||
github-token: ${{ steps.app-token.outputs.token }} | ||
github-token: ${{ steps.app-token.outputs.token }} |
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,42 @@ | ||
--- | ||
name: Code static analysis | ||
on: [pull_request] # yamllint disable-line rule:truthy | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
code-static-analysis: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Validate YAML files (best code practices check included) | ||
id: validate-yaml-files | ||
uses: ibiqlik/[email protected] | ||
with: | ||
config_file: ./ci/yamllint-config.yaml | ||
|
||
# In some YAML files we use JSON strings, let's check these | ||
- name: Validate JSON strings in YAML files (just syntax) | ||
id: validate-json-strings-in-yaml-files | ||
run: | | ||
type json_verify || sudo apt-get install yajl-tools | ||
bash ./ci/check-json.sh | ||
- name: Validate JSON files (just syntax) | ||
id: validate-json-files | ||
run: | | ||
type json_verify || sudo apt-get install yajl-tools | ||
shopt -s globstar | ||
ret_code=0 | ||
echo "-- Checking a regular '*.json' files" | ||
for f in **/*.json; do echo "Checking: '${f}"; echo -n " > "; cat $f | json_verify || ret_code=1; done | ||
echo "-- Checking a 'Pipfile.lock' files" | ||
for f in **/Pipfile.lock; do echo "Checking: '${f}"; echo -n " > "; cat $f | json_verify || ret_code=1; done | ||
echo "-- Checking a '*.ipynb' Jupyter notebook files" | ||
for f in **/*.ipynb; do echo "Checking: '${f}"; echo -n " > "; cat $f | json_verify || ret_code=1; done | ||
if test "${ret_code}" -ne 0; then | ||
echo "There were errors in some of the checked files. Please run `json_verify` on such files and fix issues there." | ||
fi | ||
exit "${ret_code}" |
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
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
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
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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
--- | ||
name: /opt/app-root | ||
channels: | ||
- defaults | ||
|
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,45 @@ | ||
#!/bin/bash | ||
# | ||
# This script serves to check YAML files in this repository that contain particular | ||
# key fields where JSON string is expected. Such JSON strings are extracted and | ||
# validated via `json_verify` tool. | ||
# | ||
# Local execution: ./ci/check-json.sh | ||
# Note: please execute from the root directory so that whole dir tree is checked | ||
# | ||
# In case of the PR on GitHub, this check is tied to GitHub actions automatically, | ||
# see `.github/workflows` directory. | ||
|
||
shopt -s globstar | ||
|
||
function check_json() { | ||
local f="${1}" | ||
local string="${2}" | ||
|
||
local ret_code=0 | ||
|
||
echo "" # Let's make some space from eventual previous file check | ||
echo "Checking: '${f}' - for '${string}':" | ||
|
||
if grep --quiet --extended-regexp "${string}" "${f}"; then | ||
#if $(grep -e "${string}" "${f}"); then | ||
jsons=$(yq -r ".spec.tags[].annotations.\"${string}\"" "${f}") | ||
|
||
while IFS= read -r json; do | ||
echo " ${json}" | ||
echo -n " > "; echo "${json}" | json_verify || ret_code="${?}" | ||
done <<< "${jsons}" | ||
else | ||
echo " Ignoring as this file doesn't contain necessary key field '${string}' for check" | ||
fi | ||
|
||
return "${ret_code}" | ||
} | ||
|
||
ret_code=0 | ||
for f in **/*.yml **/*.yaml; do | ||
check_json "${f}" "opendatahub.io/notebook-software" || ret_code="${?}" | ||
check_json "${f}" "opendatahub.io/notebook-python-dependencies" || ret_code="${?}" | ||
done | ||
|
||
exit "${ret_code}" |
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,8 @@ | ||
--- | ||
|
||
extends: default | ||
|
||
rules: | ||
line-length: disable | ||
new-line-at-end-of-file: | ||
level: warning |
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 |
---|---|---|
@@ -1,21 +1,22 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: pod | ||
labels: | ||
labels: | ||
app: codeserver-image | ||
spec: | ||
containers: | ||
- name: codeserver | ||
image: codeserver-workbench | ||
command: [ "/bin/sh", "-c", "while true ; do date; sleep 5; done;" ] | ||
imagePullPolicy: Always | ||
ports: | ||
- containerPort: 8585 | ||
resources: | ||
limits: | ||
cpu: 500m | ||
memory: 500Mi | ||
requests: | ||
cpu: 500m | ||
memory: 500Mi | ||
containers: | ||
- name: codeserver | ||
image: codeserver-workbench | ||
command: ["/bin/sh", "-c", "while true ; do date; sleep 5; done;"] | ||
imagePullPolicy: Always | ||
ports: | ||
- containerPort: 8585 | ||
resources: | ||
limits: | ||
cpu: 500m | ||
memory: 500Mi | ||
requests: | ||
cpu: 500m | ||
memory: 500Mi |
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
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
Oops, something went wrong.