Skip to content

Commit

Permalink
ci: add pre commit config
Browse files Browse the repository at this point in the history
  • Loading branch information
wuhuizuo committed Sep 5, 2024
1 parent 0f4235d commit d5b6036
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 30 deletions.
40 changes: 20 additions & 20 deletions .github/scripts/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function test_get_builder() {
for os in $operating_systems; do
for ac in $architectures; do
echo "$cm $os $ac $version:"
$script $cm $os $ac $version $profile
$script "$cm" "$os" "$ac" "$version" $profile
done
done
done
Expand All @@ -26,7 +26,7 @@ function test_get_builder() {
for os in $operating_systems; do
for ac in $architectures; do
echo "$cm $os $ac $version:"
$script $cm $os $ac $version $profile
$script "$cm" "$os" "$ac" "$version" $profile
done
done
done
Expand All @@ -38,7 +38,7 @@ function test_get_builder() {
for ac in $architectures; do
for version in v1.5.0 v1.6.0; do
echo "$cm $os $ac $version:"
$script $cm $os $ac $version $profile
$script "$cm" "$os" "$ac" "$version" $profile
done
done
# tiflow-operator
Expand All @@ -47,7 +47,7 @@ function test_get_builder() {
for ac in $architectures; do
for version in v6.4.0-20221102-1667359250 v20221018; do
echo "$cm $os $ac $version:"
$script $cm $os $ac $version $profile
$script "$cm" "$os" "$ac" "$version" $profile
done
done

Expand All @@ -57,7 +57,7 @@ function test_get_builder() {
for ac in $architectures; do
for version in v0.5.0 v0.6.0; do
echo "$cm $os $ac $version:"
$script $cm $os $ac $version $profile
$script "$cm" "$os" "$ac" "$version" $profile
done
done

Expand All @@ -67,7 +67,7 @@ function test_get_builder() {
for ac in $architectures; do
for version in v0.1.2 v0.1.3; do
echo "$cm $os $ac $version:"
$script $cm $os $ac $version $profile
$script "$cm" "$os" "$ac" "$version" $profile
done
done
}
Expand All @@ -85,7 +85,7 @@ function test_gen_package_artifacts_script() {
for os in $operating_systems; do
for ac in $architectures; do
echo "$cm $os $ac $version:"
$script $cm $os $ac $version $profile branch-xxx 123456789abcdef
$script "$cm" "$os" "$ac" "$version" $profile branch-xxx 123456789abcdef
shellcheck -S error packages/scripts/build-package-artifacts.sh
done
done
Expand All @@ -98,7 +98,7 @@ function test_gen_package_artifacts_script() {
for os in $operating_systems; do
for ac in $architectures; do
echo "$cm $os $ac $version:"
$script $cm $os $ac $version enterprise branch-xxx 123456789abcdef
$script "$cm" "$os" "$ac" "$version" enterprise branch-xxx 123456789abcdef
shellcheck -S error packages/scripts/build-package-artifacts.sh
done
done
Expand All @@ -111,7 +111,7 @@ function test_gen_package_artifacts_script() {
for os in $operating_systems; do
for ac in $architectures; do
echo "$cm $os $ac $version:"
$script $cm $os $ac $version failpoint branch-xxx 123456789abcdef
$script "$cm" "$os" "$ac" "$version" failpoint branch-xxx 123456789abcdef
shellcheck -S error packages/scripts/build-package-artifacts.sh
done
done
Expand All @@ -125,7 +125,7 @@ function test_gen_package_artifacts_script() {
for ac in $architectures; do
for version in v1.5.0 v1.6.0; do
echo "$cm $os $ac $version:"
$script $cm $os $ac $version $profile branch-xxx 123456789abcdef
$script "$cm" "$os" "$ac" "$version" $profile branch-xxx 123456789abcdef
shellcheck -S error packages/scripts/build-package-artifacts.sh
done
done
Expand All @@ -136,7 +136,7 @@ function test_gen_package_artifacts_script() {
for ac in $architectures; do
for version in v6.4.0-20221102-1667359250 v20221018; do
echo "$cm $os $ac $version:"
$script $cm $os $ac $version $profile branch-xxx 123456789abcdef
$script "$cm" "$os" "$ac" "$version" $profile branch-xxx 123456789abcdef
shellcheck -S error packages/scripts/build-package-artifacts.sh
done
done
Expand All @@ -147,7 +147,7 @@ function test_gen_package_artifacts_script() {
for ac in $architectures; do
for version in v0.5.0 v0.6.0; do
echo "$cm $os $ac $version:"
$script $cm $os $ac $version $profile branch-xxx 123456789abcdef
$script "$cm" "$os" "$ac" "$version" $profile branch-xxx 123456789abcdef
shellcheck -S error packages/scripts/build-package-artifacts.sh
done
done
Expand All @@ -158,7 +158,7 @@ function test_gen_package_artifacts_script() {
for ac in $architectures; do
for version in v0.1.2 v0.1.3; do
echo "$cm $os $ac $version:"
$script $cm $os $ac $version $profile branch-xxx 123456789abcdef
$script "$cm" "$os" "$ac" "$version" $profile branch-xxx 123456789abcdef
shellcheck -S error packages/scripts/build-package-artifacts.sh
done
done
Expand All @@ -175,7 +175,7 @@ function test_gen_package_images_script() {
for cm in $components; do
for ac in $architectures; do
echo "$cm $os $ac $version:"
$script $cm linux $ac $version $profile branch-xxx 123456789abcdef
$script "$cm" linux "$ac" "$version" "$profile" branch-xxx 123456789abcdef
shellcheck -S error packages/scripts/build-package-images.sh
done
done
Expand All @@ -186,7 +186,7 @@ function test_gen_package_images_script() {
for version in $versions; do
for ac in $architectures; do
echo "$cm $os $ac $version:"
$script $cm linux $ac $version $profile branch-xxx 123456789abcdef
$script "$cm" linux "$ac" "$version" "$profile" branch-xxx 123456789abcdef
shellcheck -S error packages/scripts/build-package-images.sh
done
done
Expand All @@ -198,7 +198,7 @@ function test_gen_package_images_script() {
for ac in $architectures; do
for version in v1.6.0 v1.5.0; do
echo "$cm $os $ac $version:"
$script $cm linux $ac $version $profile branch-xxx 123456789abcdef
$script "$cm" linux "$ac" "$version" "$profile" branch-xxx 123456789abcdef
shellcheck -S error packages/scripts/build-package-images.sh
done
done
Expand All @@ -208,7 +208,7 @@ function test_gen_package_images_script() {
for ac in $architectures; do
for version in v6.4.0-20221102-1667359250 v20221018; do
echo "$cm $os $ac $version:"
$script $cm linux $ac $version $profile branch-xxx 123456789abcdef
$script "$cm" linux "$ac" "$version" "$profile" branch-xxx 123456789abcdef
shellcheck -S error packages/scripts/build-package-images.sh
done
done
Expand All @@ -219,7 +219,7 @@ function test_gen_package_images_script() {
for version in v0.5.0 v0.6.0; do
for ac in $architectures; do
echo "$cm $os $ac $version:"
$script $cm linux $ac $version $profile branch-xxx 123456789abcdef
$script "$cm" linux "$ac" "$version" "$profile" branch-xxx 123456789abcdef
shellcheck -S error packages/scripts/build-package-images.sh
done
done
Expand All @@ -230,7 +230,7 @@ function test_gen_package_images_script() {
for ac in $architectures; do
for version in v0.1.2 v0.1.3; do
echo "$cm $os $ac $version:"
$script $cm linux $ac $version $profile branch-xxx 123456789abcdef
$script "$cm" linux "$ac" "$version" "$profile" branch-xxx 123456789abcdef
shellcheck -S error packages/scripts/build-package-images.sh
done
done
Expand All @@ -248,7 +248,7 @@ function test_gen_offline_package_artifacts_script() {
for ac in $architectures; do
for edition in $editions; do
echo "$os $ac $version $edition:"
$script $os $ac $version $edition
$script "$os" "$ac" "$version" "$edition"
shellcheck -S error packages/scripts/compose-offline-packages-artifacts.sh
done
done
Expand Down
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
ci:
autofix_commit_msg: |
fix: auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
autoupdate_commit_msg: "chore: pre-commit autoupdate"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
hooks:
- id: shellcheck
- repo: https://github.com/gitleaks/gitleaks
rev: v8.16.1
hooks:
- id: gitleaks
20 changes: 10 additions & 10 deletions dockerfiles/bases/build-old.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ build() {
case "${PLATFORMS}" in
linux/amd64)
echo "building for linux/amd64 platform..."
docker build --tag=$IMAGE --platform=$PLATFORMS --target amd64 . -f "$dockerfile"
docker build --tag="$IMAGE" --platform="$PLATFORMS" --target amd64 . -f "$dockerfile"
if $PUSH_IMAGE; then
docker push $IMAGE
docker push "$IMAGE"
fi
;;
linux/arm64)
echo "building for linux/arm64 platform..."
docker build --tag=$IMAGE --platform=$PLATFORMS --target arm64 . -f "$dockerfile"
docker build --tag="$IMAGE" --platform="$PLATFORMS" --target arm64 . -f "$dockerfile"
if $PUSH_IMAGE; then
docker push $IMAGE
docker push "$IMAGE"
fi
;;
linux/arm64,linux/amd64 | linux/amd64,linux/arm64)
echo "building for linux/arm64 and linux/amd64 platforms..."
docker build --tag=${IMAGE}_linux_amd64 --platform=linux/amd64 --target amd64 . -f "$dockerfile"
docker build --tag=${IMAGE}_linux_arm64 --platform=linux/arm64 --target arm64 . -f "$dockerfile"
docker build --tag="${IMAGE}_linux_amd64" --platform=linux/amd64 --target amd64 . -f "$dockerfile"
docker build --tag="${IMAGE}_linux_arm64" --platform=linux/arm64 --target arm64 . -f "$dockerfile"
if $PUSH_IMAGE; then
docker push ${IMAGE}_linux_amd64
docker push ${IMAGE}_linux_arm64
docker push "${IMAGE}_linux_amd64"
docker push "${IMAGE}_linux_arm64"

# compose manifest for multi-arch image.
pushed_repo="${IMAGE%:*}"
Expand All @@ -35,14 +35,14 @@ build() {
yq -i ".tags = [\"$tag\"]" manifest.yaml

# linux/amd64
manifest-tool inspect --raw ${IMAGE}_linux_amd64 >manifest_linux_amd64.json
manifest-tool inspect --raw "${IMAGE}_linux_amd64" >manifest_linux_amd64.json
yq -i '.manifests += [{}]' manifest.yaml
digest=$(jq -r '.digest' manifest_linux_amd64.json)
yq -i ".manifests[-1].image = \"${pushed_repo}@${digest}\"" manifest.yaml
yq -i '.manifests[-1].platform.os = "linux"' manifest.yaml
yq -i '.manifests[-1].platform.architecture = "amd64"' manifest.yaml
# linux/arm64
manifest-tool inspect --raw ${IMAGE}_linux_arm64 >manifest_linux_arm64.json
manifest-tool inspect --raw "${IMAGE}_linux_arm64" >manifest_linux_arm64.json
yq -i '.manifests += [{}]' manifest.yaml
digest=$(jq -r '.digest' manifest_linux_arm64.json)
yq -i ".manifests[-1].image = \"${pushed_repo}@${digest}\"" manifest.yaml
Expand Down

0 comments on commit d5b6036

Please sign in to comment.