Skip to content

Commit

Permalink
ci: add concurrent test suites
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <xpf6677@163.com>
  • Loading branch information
Peefy committed May 14, 2024
1 parent 52d0f10 commit b8dbe5c
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 26 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/example-e2e-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ jobs:
shell: bash -ieo pipefail {0}
run: PATH=$PATH:$HOME/go/bin ./examples/test.sh

- name: run concurrent e2e
run: PATH=$PATH:$HOME/go/bin ./scripts/concurrent_test.sh

macos:
strategy:
matrix:
Expand All @@ -43,6 +46,9 @@ jobs:
shell: bash -ieo pipefail {0}
run: PATH=$PATH:$HOME/go/bin ./examples/test.sh

- name: run concurrent e2e
run: PATH=$PATH:$HOME/go/bin ./scripts/concurrent_test.sh

windows:
runs-on: windows-latest
steps:
Expand Down
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ RUN apt-get update
RUN apt-get install gcc git -y
# The reason for doing this below is to prevent the
# container from not having write permissions.
ENV KCL_GO_DISABLE_INSTALL_ARTIFACT=true
ENV KCL_PKG_PATH=/tmp
ENV KCL_CACHE_PATH=/tmp

# In the image, we can generate a runtime in advance to
# avoid writing files in the image
ENV KCL_GO_DISABLE_INSTALL_ARTIFACT=true
ENV KCL_GO_DISABLE_ARTIFACT_IN_PATH=false
# Install the tini
ENV TINI_VERSION v0.19.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ export PATH=$KCL_CLI_INSTALLATION_PATH:$PATH
docker run -it kcllang/kcl
```

### Docker for arm64

```shell
docker run -it kcllang/kcl-arm64
```

### Build from Source Code

```shell
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.8.9
0.9.0-alpha.1
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ require (
github.com/onsi/ginkgo/v2 v2.17.3
github.com/onsi/gomega v1.33.1
github.com/spf13/cobra v1.8.0
kcl-lang.io/kcl-go v0.8.7
kcl-lang.io/kcl-go v0.9.0-alpha.1
kcl-lang.io/kcl-openapi v0.6.1
kcl-lang.io/kcl-playground v0.5.1
kcl-lang.io/kpm v0.8.6
kcl-lang.io/kpm v0.8.7-0.20240511160903-faa726d7169b
)

require (
Expand Down Expand Up @@ -178,7 +178,7 @@ require (
golang.org/x/tools v0.20.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.34.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand All @@ -191,7 +191,7 @@ require (
k8s.io/klog/v2 v2.100.1 // indirect
k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect
k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 // indirect
kcl-lang.io/lib v0.8.7 // indirect
kcl-lang.io/lib v0.9.0-alpha.1.0.20240513115021-7408627a80ec // indirect
oras.land/oras-go v1.2.3 // indirect
oras.land/oras-go/v2 v2.3.0 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1658,8 +1658,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.34.0 h1:Qo/qEd2RZPCf2nKuorzksSknv0d3ERwp1vFG38gSmH4=
google.golang.org/protobuf v1.34.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down Expand Up @@ -1735,16 +1735,16 @@ k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 h1:qY1Ad8PODbnymg2pRbkyMT/ylpTrCM8P2RJ0yroCyIk=
k8s.io/utils v0.0.0-20230406110748-d93618cff8a2/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
kcl-lang.io/kcl-go v0.8.7 h1:KekBSkoZYWupMjsC0yX3bCQzEvFTI9HTpKREvWrvu/8=
kcl-lang.io/kcl-go v0.8.7/go.mod h1:PjOAZXoCdmx+rz/zybRNLQWvybnU4z4gbKDW7IwUDH4=
kcl-lang.io/kcl-go v0.9.0-alpha.1 h1:X4phg09tX0GR7QBXwykPeo4HzzQanMV2ToeJm+mj7Xw=
kcl-lang.io/kcl-go v0.9.0-alpha.1/go.mod h1:X4aDVk46f8meaP/IUQiFz3gKvO/SB02IJAWbL66IHfo=
kcl-lang.io/kcl-openapi v0.6.1 h1:iPH0EvPgDGZS5Lk00/Su5Av6AQP5IBG8f7gAUyevkHE=
kcl-lang.io/kcl-openapi v0.6.1/go.mod h1:Ai9mFztCVKkRSFabczO/r5hCNdqaNtAc2ZIRxTeV0Mk=
kcl-lang.io/kcl-playground v0.5.1 h1:MKQQUHgt4+2QyU2NVwa73oksOaBJGDi4keGoggA0MiU=
kcl-lang.io/kcl-playground v0.5.1/go.mod h1:IFmnlw7m011ccX8OidMUfnnN2u/TWdtQGxyABRTbmow=
kcl-lang.io/kpm v0.8.6 h1:uGaZjfkyG2ot9xVqdbE7ZsHcUfi6qYDa3UZUM77hhR8=
kcl-lang.io/kpm v0.8.6/go.mod h1:buvccvOf1JdN9WiPG1bOYHUnzapWNBLfURJf8W/VswU=
kcl-lang.io/lib v0.8.7 h1:qN7FOrwd8l4IiuPUDEEIKJqavGAq+rTMR1GCn0OrydE=
kcl-lang.io/lib v0.8.7/go.mod h1:ubsalGXxJaa5II/EsHmsI/tL2EluYHIcW+BwzQPt+uY=
kcl-lang.io/kpm v0.8.7-0.20240511160903-faa726d7169b h1:Bduk9oA+5UnbksE486EDbp6oq1VScqF1S8/PKiypG94=
kcl-lang.io/kpm v0.8.7-0.20240511160903-faa726d7169b/go.mod h1:buvccvOf1JdN9WiPG1bOYHUnzapWNBLfURJf8W/VswU=
kcl-lang.io/lib v0.9.0-alpha.1.0.20240513115021-7408627a80ec h1:93Wwpa9OIT2HlYX6DDhOYP9Azv4SlPtLeyWuTIY1kO0=
kcl-lang.io/lib v0.9.0-alpha.1.0.20240513115021-7408627a80ec/go.mod h1:ubsalGXxJaa5II/EsHmsI/tL2EluYHIcW+BwzQPt+uY=
oras.land/oras-go v1.2.3 h1:v8PJl+gEAntI1pJ/LCrDgsuk+1PKVavVEPsYIHFE5uY=
oras.land/oras-go v1.2.3/go.mod h1:M/uaPdYklze0Vf3AakfarnpoEckvw0ESbRdN8Z1vdJg=
oras.land/oras-go/v2 v2.3.0 h1:lqX1aXdN+DAmDTKjiDyvq85cIaI4RkIKp/PghWlAGIU=
Expand Down
13 changes: 2 additions & 11 deletions pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ func getVersion(version string) string {
}

const (
VersionTypeLatest = Version_0_8_9
VersionTypeLatest = Version_0_9_0_alpha_1

Version_0_9_0_alpha_1 VersionType = "0.9.0-alpha.1"
Version_0_8_9 VersionType = "0.8.9"
Version_0_8_8 VersionType = "0.8.8"
Version_0_8_7 VersionType = "0.8.7"
Expand All @@ -44,21 +45,11 @@ const (
Version_0_8_2 VersionType = "0.8.2"
Version_0_8_1 VersionType = "0.8.1"
Version_0_8_0 VersionType = "0.8.0"
Version_0_8_0_beta_1 VersionType = "0.8.0-beta.1"
Version_0_8_0_alpha_1 VersionType = "0.8.0-alpha.1"
Version_0_7_5 VersionType = "0.7.5"
Version_0_7_4 VersionType = "0.7.4"
Version_0_7_3 VersionType = "0.7.3"
Version_0_7_2 VersionType = "0.7.2"
Version_0_7_1 VersionType = "0.7.1"
Version_0_7_0 VersionType = "0.7.0"
Version_0_7_0_beta_2 VersionType = "0.7.0-beta.2"
Version_0_7_0_beta_1 VersionType = "0.7.0-beta.1"
Version_0_7_0_alpha_2 VersionType = "0.7.0-alpha.2"
Version_0_7_0_alpha_1 VersionType = "0.7.0-alpha.1"
Version_0_6_0 VersionType = "0.6.0"
Version_0_6_0_alpha_1 VersionType = "0.6.0-alpha.1"
Version_0_6_0_alpha_2 VersionType = "0.6.0-alpha.2"
Version_0_6_0_alpha_3 VersionType = "0.6.0-alpha.3"
Version_0_6_0_alpha_4 VersionType = "0.6.0-alpha.4"
)
55 changes: 55 additions & 0 deletions scripts/concurrent_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

concurrent_test() {
local repo_url=$1
local concurrency=$2

local -a statuses
for i in $(seq 1 "$concurrency"); do
statuses[i]=0
done

run_test() {
local id=$1
echo "Starting test for $repo_url (ID: $id)"
if time kcl run "$repo_url"; then
echo "Completed test successfully for $repo_url (ID: $id)"
statuses[id]=0
else
echo "Test failed for $repo_url (ID: $id)"
statuses[id]=$?
fi
}

for i in $(seq 1 "$concurrency"); do
run_test "$i" &
done

wait

local has_errors=0
for status in "${statuses[@]}"; do
if [ "$status" -ne 0 ]; then
has_errors=1
break
fi
done

return $has_errors
}

TEST_REPOS=(
"oci://ghcr.io/kcl-lang/podinfo"
"https://github.com/kcl-lang/flask-demo-kcl-manifests"
"./examples/server"
)
CONCURRENCY_LEVEL=4

for repo in "${TEST_REPOS[@]}"; do
if ! concurrent_test "$repo" "$CONCURRENCY_LEVEL"; then
echo "Error during concurrent test for $repo"
exit 1
fi
done

echo "All concurrent tests completed successfully."

0 comments on commit b8dbe5c

Please sign in to comment.