diff --git a/.github/workflows/bootstrap.yaml b/.github/workflows/bootstrap.yaml index 41dac5a..3e1df48 100644 --- a/.github/workflows/bootstrap.yaml +++ b/.github/workflows/bootstrap.yaml @@ -91,9 +91,10 @@ jobs: # Only updates file if it has changed selective_file_copy() { # Receives a single file path as argument - SHA_SRC=$(sha1sum "$DEVOPS_DIR"/"$1" | awk '{print $1}') - SHA_DST=$(sha1sum "$1" 2>/dev/null | awk '{print $1}' || :) - if [ "$SHA_SRC" != "$SHA_DST" ]; then + # SHA_SRC=$(sha1sum "$DEVOPS_DIR/$1" | awk '{print $1}') + # SHA_DST=$(sha1sum "$1" 2>/dev/null | awk '{print $1}' || :) + # if [ "$SHA_SRC" != "$SHA_DST" ]; then + if ! (cmp "$DEVOPS_DIR/$1" "$1"); then echo "Copying: $1" cp "$DEVOPS_DIR/$1" "$1" git add "$1" diff --git a/.github/workflows/notebooks.yaml b/.github/workflows/notebooks.yaml index c235e1d..83b5c5f 100644 --- a/.github/workflows/notebooks.yaml +++ b/.github/workflows/notebooks.yaml @@ -50,9 +50,9 @@ jobs: pip install . pip install pytest nbmake - - name: "Test notebooks: pytest --nbmake" + - name: "Testing notebooks" run: | - echo "testing notebooks" + echo "Testing notebooks using: pytest --nbmake -- **/test_*.ipynb" pytest --nbmake -- **/test_*.ipynb - name: Upload logs as artefacts diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4f4725f..1dac879 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -65,11 +65,11 @@ repos: - id: markdownlint args: ["--fix"] - - repo: https://github.com/psf/black-pre-commit-mirror - rev: 24.4.2 - hooks: - - id: black - - id: black-jupyter + # - repo: https://github.com/psf/black-pre-commit-mirror + # rev: 24.4.2 + # hooks: + # - id: black + # - id: black-jupyter # - repo: https://github.com/tomcatling/black-nb # rev: '0.7' @@ -113,6 +113,8 @@ repos: rev: "7.0.0" hooks: - id: flake8 + additional_dependencies: + - pep8-naming - repo: https://github.com/adrienverge/yamllint.git rev: v1.35.1 @@ -125,11 +127,11 @@ repos: hooks: - id: mypy verbose: true - args: [--show-error-codes] + args: ["--show-error-codes", "--install-types", "--non-interactive"] additional_dependencies: ["pytest", "types-requests"] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.4.3 + rev: v0.4.4 hooks: - id: ruff files: ^(scripts|tests|custom_components)/.+\.py$ diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 83afb31..ac070c2 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -11,6 +11,7 @@ SOURCE_FILE="bootstrap.yaml" WGET_URL="https://raw.githubusercontent.com/os-climate/devops-toolkit/main/.github/workflows/$SOURCE_FILE" AUTOMATION_BRANCH="update-devops-tooling" DEVOPS_DIR=".devops" +FETCH_MODE="wget" ### Checks ### @@ -21,7 +22,8 @@ fi WGET_CMD=$(which wget) if [ ! -x "$WGET_CMD" ]; then - echo "WGET command was NOT found in PATH"; exit 1 + echo "WGET command was NOT found in PATH; using CURL" + FETCH_MODE="curl" fi MKTEMP_CMD=$(which mktemp) @@ -29,6 +31,8 @@ if [ ! -x "$MKTEMP_CMD" ]; then echo "MKTEMP command was NOT found in PATH"; exit 1 fi + + SHELL_SCRIPT=$(mktemp -t script-XXXXXXXX.sh) ### Functions ### @@ -95,9 +99,15 @@ if [ -f "$SOURCE_FILE" ]; then echo "Removing existing copy of: $SOURCE_FILE" rm "$SOURCE_FILE" fi -echo "Pulling latest DevOps bootstrap workflow from:" +echo "Pulling latest DevOps bootstrap YAML from:" echo " $WGET_URL" -"$WGET_CMD" -q "$WGET_URL" +if [ "$FETCH_MODE" = "wget" ]; then + "$WGET_CMD" -q "$WGET_URL" > /dev/null 2>&1 +fi +if [ ! -f "$SOURCE_FILE" ]; then + echo "Attempting to retrieve YAML file with CURL" + curl "$WGET_URL" > "$SOURCE_FILE" +fi # The section below extracts shell code from the YAML file echo "Extracting shell code from: $SOURCE_FILE"