From eeb7508b6d43adf93b981a3affc0ce4076c68136 Mon Sep 17 00:00:00 2001 From: cndoit18 Date: Tue, 25 Mar 2025 12:16:18 +0800 Subject: [PATCH] ci: add CI workflow to run tests on push and pull requests to master Change-Id: I0e44649554fa33d0bedfe7da8b2c155cf490144d --- .github/workflows/ci.yaml | 38 +++++++++++++++++++ Rakefile | 6 ++- tests/00gvm_install_comment_test.sh | 18 ++++----- tests/gvm_alias_comment_test.sh | 14 +++---- tests/gvm_use_comment_test.sh | 8 ++-- .../gvm_install_1.2.2_binary_comment_test.sh | 1 - .../gvm_install_1.20.2_comment_test.sh | 1 + .../gvm_install_1.21.3_binary_comment_test.sh | 1 + ...nstall_1.23.5_preferbinary_comment_test.sh | 1 + .../gvm_install_1.4.3_comment_test.sh | 1 - ...install_1.4.3_preferbinary_comment_test.sh | 1 - 11 files changed, 65 insertions(+), 25 deletions(-) create mode 100644 .github/workflows/ci.yaml delete mode 100644 tests/scenario/gvm_install_1.2.2_binary_comment_test.sh create mode 100644 tests/scenario/gvm_install_1.20.2_comment_test.sh create mode 100644 tests/scenario/gvm_install_1.21.3_binary_comment_test.sh create mode 100644 tests/scenario/gvm_install_1.23.5_preferbinary_comment_test.sh delete mode 100644 tests/scenario/gvm_install_1.4.3_comment_test.sh delete mode 100644 tests/scenario/gvm_install_1.4.3_preferbinary_comment_test.sh diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000..4956a570 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,38 @@ +name: CI + +on: + push: + branches: ["master"] + pull_request: + branches: ["master"] + +permissions: + contents: read + +jobs: + test: + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + runs-on: ${{ matrix.os }} + + env: + GVM_NO_GIT_BAK: 1 + GVM_NO_UPDATE_PROFILE: 1 + SRC_REPO: ${{ github.repositoryUrl }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: "1.17" + - name: Before install + run: binscripts/gvm-installer ${{ github.sha }} tmp + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: "3.3" + bundler-cache: true + - name: Run tests + run: |- + gem install tf -v '>=0.4.1' + rake default scenario diff --git a/Rakefile b/Rakefile index 40b6fc7e..e3b0fbee 100644 --- a/Rakefile +++ b/Rakefile @@ -14,9 +14,10 @@ task :default do Dir.mktmpdir('gvm-test') do |tmpdir| system(<<-EOSH) || fail bash -c ' - set -e #{root_path}/binscripts/gvm-installer #{commit} #{tmpdir} source #{tmpdir}/gvm/scripts/gvm + + set -e tf --text #{tmpdir}/gvm/tests/*.sh ' EOSH @@ -30,9 +31,10 @@ task :scenario do Dir.mktmpdir('gvm-test') do |tmpdir| system(<<-EOSH) || fail bash -c ' - set -e #{root_path}/binscripts/gvm-installer #{commit} #{tmpdir} source #{tmpdir}/gvm/scripts/gvm + + set -e tf --text #{tmpdir}/gvm/tests/scenario/#{name} ' EOSH diff --git a/tests/00gvm_install_comment_test.sh b/tests/00gvm_install_comment_test.sh index c4371a3d..889dceaf 100644 --- a/tests/00gvm_install_comment_test.sh +++ b/tests/00gvm_install_comment_test.sh @@ -1,14 +1,14 @@ ## Cleanup test objects -gvm uninstall go1.4.3 > /dev/null 2>&1 +gvm uninstall go1.20.7 > /dev/null 2>&1 gvm uninstall master > /dev/null 2>&1 -gvm uninstall go1.6.4 > /dev/null 2>&1 -gvm uninstall go1.7.6 > /dev/null 2>&1 +gvm uninstall go1.21.4 > /dev/null 2>&1 +gvm uninstall go1.23.6 > /dev/null 2>&1 ####################### -gvm install go1.4.3 #status=0 -GOROOT_BOOTSTRAP=$GVM_ROOT/gos/go1.4.3 gvm install master #status=0 +gvm install go1.20.7 #status=0 +GOROOT_BOOTSTRAP=$GVM_ROOT/gos/go1.20.7 gvm install go1.21.4 #status=0 +gvm list #status=0; match=/go1.21.4/ +GOROOT_BOOTSTRAP=$GVM_ROOT/gos/go1.20.7 gvm install go1.23.6 #status=0 +gvm list #status=0; match=/go1.23.6/ +GOROOT_BOOTSTRAP=$GVM_ROOT/gos/go1.23.6 gvm install master #status=0 gvm list #status=0; match=/master/ -GOROOT_BOOTSTRAP=$GVM_ROOT/gos/go1.4.3 gvm install go1.6.4 #status=0 -gvm list #status=0; match=/go1.6.4/ -GOROOT_BOOTSTRAP=$GVM_ROOT/gos/go1.4.3 gvm install go1.7.6 #status=0 -gvm list #status=0; match=/go1.7.6/ diff --git a/tests/gvm_alias_comment_test.sh b/tests/gvm_alias_comment_test.sh index 04f726e1..eeee72b8 100644 --- a/tests/gvm_alias_comment_test.sh +++ b/tests/gvm_alias_comment_test.sh @@ -6,14 +6,14 @@ gvm alias delete bar ####################### gvm alias # status=0 -gvm alias create foo go1.7.6 # status=0 -gvm alias create bar go1.6.4 # status=0 -gvm alias list # status=0; match=/gvm go aliases/; match=/foo \(go1\.7\.6\)/; match=/bar \(go1\.6\.4\)/ +gvm alias create foo go1.23.6 # status=0 +gvm alias create bar go1.21.4 # status=0 +gvm alias list # status=0; match=/gvm go aliases/; match=/foo \(go1\.23\.6\)/; match=/bar \(go1\.21\.4\)/ gvm use foo # status=0 -go version # status=0; match=/go1\.7\.6/ +go version # status=0; match=/go1\.23\.6/ gvm use bar # status=0 -go version # status=0; match=/go1\.6\.4/ +go version # status=0; match=/go1\.21\.4/ gvm alias delete foo -gvm alias list # status=0; match=/gvm go aliases/; match!=/foo \(go1\.7\.6\)/; match=/bar \(go1\.6\.4\)/ +gvm alias list # status=0; match=/gvm go aliases/; match!=/foo \(go1\.23\.6\)/; match=/bar \(go1\.21\.4\)/ gvm alias delete bar -gvm alias list # status=0; match=/gvm go aliases/; match!=/foo \(go1\.7\.6\)/; match!=/bar \(go1\.6\.4\)/ +gvm alias list # status=0; match=/gvm go aliases/; match!=/foo \(go1\.23\.6\)/; match!=/bar \(go1\.21\.4\)/ diff --git a/tests/gvm_use_comment_test.sh b/tests/gvm_use_comment_test.sh index 0108e8be..40b18aaa 100644 --- a/tests/gvm_use_comment_test.sh +++ b/tests/gvm_use_comment_test.sh @@ -1,5 +1,5 @@ source $GVM_ROOT/scripts/gvm -gvm use go1.7.6 # status=0 -go version # status=0; match=/go1\.7\.6/ -gvm use go1.6.4 # status=0 -go version # status=0; match=/go1\.6\.4/ +gvm use go1.23.6 # status=0 +go version # status=0; match=/go1\.23\.6/ +gvm use go1.21.4 # status=0 +go version # status=0; match=/go1\.21\.4/ diff --git a/tests/scenario/gvm_install_1.2.2_binary_comment_test.sh b/tests/scenario/gvm_install_1.2.2_binary_comment_test.sh deleted file mode 100644 index efe4f68a..00000000 --- a/tests/scenario/gvm_install_1.2.2_binary_comment_test.sh +++ /dev/null @@ -1 +0,0 @@ -gvm install go1.2.2 --binary #status=0 diff --git a/tests/scenario/gvm_install_1.20.2_comment_test.sh b/tests/scenario/gvm_install_1.20.2_comment_test.sh new file mode 100644 index 00000000..5e0e88e9 --- /dev/null +++ b/tests/scenario/gvm_install_1.20.2_comment_test.sh @@ -0,0 +1 @@ +gvm install go1.20.2 #status=0 diff --git a/tests/scenario/gvm_install_1.21.3_binary_comment_test.sh b/tests/scenario/gvm_install_1.21.3_binary_comment_test.sh new file mode 100644 index 00000000..c62719e3 --- /dev/null +++ b/tests/scenario/gvm_install_1.21.3_binary_comment_test.sh @@ -0,0 +1 @@ +gvm install go1.21.3 --binary #status=0 diff --git a/tests/scenario/gvm_install_1.23.5_preferbinary_comment_test.sh b/tests/scenario/gvm_install_1.23.5_preferbinary_comment_test.sh new file mode 100644 index 00000000..1393b8f0 --- /dev/null +++ b/tests/scenario/gvm_install_1.23.5_preferbinary_comment_test.sh @@ -0,0 +1 @@ +gvm install go1.23.5 --prefer-binary #status=0 diff --git a/tests/scenario/gvm_install_1.4.3_comment_test.sh b/tests/scenario/gvm_install_1.4.3_comment_test.sh deleted file mode 100644 index b5d8550b..00000000 --- a/tests/scenario/gvm_install_1.4.3_comment_test.sh +++ /dev/null @@ -1 +0,0 @@ -gvm install go1.4.3 #status=0 \ No newline at end of file diff --git a/tests/scenario/gvm_install_1.4.3_preferbinary_comment_test.sh b/tests/scenario/gvm_install_1.4.3_preferbinary_comment_test.sh deleted file mode 100644 index c7740d9c..00000000 --- a/tests/scenario/gvm_install_1.4.3_preferbinary_comment_test.sh +++ /dev/null @@ -1 +0,0 @@ -gvm install go1.4.3 --prefer-binary #status=0