diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ceee10c0beabd218bb3de1705109e53debc95d45..47299e3e021e4a81ffefe0d5fe2ee5b0493749ad 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -111,6 +111,20 @@ check-backports: - make backports - git diff --exit-code +shellcheck: + stage: test + needs: [] + image: koalaman/shellcheck-alpine:v0.9.0 + script: + - shellcheck ./src/gitlab-tofu.sh + - shellcheck ./.gitlab/scripts/*.sh + rules: + - changes: + - src/gitlab-tofu.sh + - .gitlab/scripts/*.sh + - if: $CI_COMMIT_TAG + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + container_scanning: extends: .opentofu-versions rules: diff --git a/.gitlab/scripts/fetch-states.sh b/.gitlab/scripts/fetch-states.sh index 693739a67b8933a51580e5cca08b0b0ed868d0a0..4a2982891bf2d32d92c7fc13ac4b30af1a115c48 100755 --- a/.gitlab/scripts/fetch-states.sh +++ b/.gitlab/scripts/fetch-states.sh @@ -34,7 +34,7 @@ while $has_next_page; do data=$(curl --silent --show-error --fail -H "Authorization: Bearer $GITLAB_TOKEN" -H "Content-Type: application/json" \ "$CI_API_GRAPHQL_URL" \ -X POST \ - --data '[{ "operationName": "getStates", "variables": { "projectPath": "'$CI_PROJECT_PATH'", "first": 100, "after":'"$after"', "last": null, "before": null }, "query": "query getStates($projectPath: ID!, $first: Int, $last: Int, $before: String, $after: String) { project(fullPath: $projectPath) { id terraformStates(first: $first, last: $last, before: $before, after: $after) { count nodes { name updatedAt } pageInfo { hasNextPage endCursor } } } } " } ] ' + --data '[{ "operationName": "getStates", "variables": { "projectPath": "'"$CI_PROJECT_PATH"'", "first": 100, "after":'"$after"', "last": null, "before": null }, "query": "query getStates($projectPath: ID!, $first: Int, $last: Int, $before: String, $after: String) { project(fullPath: $projectPath) { id terraformStates(first: $first, last: $last, before: $before, after: $after) { count nodes { name updatedAt } pageInfo { hasNextPage endCursor } } } } " } ] ' ) echo "$data" | jq --arg date "$FETCH_OLDER_THAN" -r '.[0]["data"]["project"]["terraformStates"]["nodes"][] | select(.updatedAt < $date) | "\(.name),\(.updatedAt)"'