From f980db774a65b7dadd87318b83660835757e055a Mon Sep 17 00:00:00 2001 From: suyanhanx Date: Sun, 29 Oct 2023 15:45:02 +0800 Subject: [PATCH 1/2] refactor(services/sftp): migrate to test planner Signed-off-by: suyanhanx --- .../sftp/sftp-default-root/action.yml | 47 ++++++++ .github/services/sftp/sftp/action.yml | 43 ++++++++ .github/workflows/service_test_sftp.yml | 102 ------------------ 3 files changed, 90 insertions(+), 102 deletions(-) create mode 100644 .github/services/sftp/sftp-default-root/action.yml create mode 100644 .github/services/sftp/sftp/action.yml diff --git a/.github/services/sftp/sftp-default-root/action.yml b/.github/services/sftp/sftp-default-root/action.yml new file mode 100644 index 000000000000..19f7c9a0a3de --- /dev/null +++ b/.github/services/sftp/sftp-default-root/action.yml @@ -0,0 +1,47 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +name: sftp-default-root +description: 'Behavior test for SFTP with default root' + +runs: + using: "composite" + steps: + - name: Setup sftp + shell: bash + run: | + mkdir -p target/ssh + ssh-keygen -t rsa -b 4096 -f target/ssh/id_rsa -q -N "" < /dev/null + tmpScript="$(mktemp)" + echo "sed -i -e 's#ForceCommand internal-sftp#ForceCommand internal-sftp -d /upload#' /etc/ssh/sshd_config" > "$tmpScript" + chmod +x "$tmpScript" + docker run \ + -v "$tmpScript:/etc/sftp.d/change_root_dir" \ + -v `pwd`/target/ssh/id_rsa.pub:/home/foo/.ssh/keys/id_rsa.pub:ro \ + --ulimit nofile=65536:65536 \ + -p 2222:22 -d atmoz/sftp \ + foo::::upload + - name: Setup + shell: bash + run: | + cat << EOF >> $GITHUB_ENV + OPENDAL_SFTP_ENDPOINT=ssh://127.0.0.1:2222 + OPENDAL_SFTP_USER=foo + OPENDAL_SFTP_KEY=${{ github.workspace }}/target/ssh/id_rsa + OPENDAL_SFTP_KNOWN_HOSTS_STRATEGY=accept + OPENDAL_DISABLE_RANDOM_ROOT=true + EOF diff --git a/.github/services/sftp/sftp/action.yml b/.github/services/sftp/sftp/action.yml new file mode 100644 index 000000000000..d4e5ace81f51 --- /dev/null +++ b/.github/services/sftp/sftp/action.yml @@ -0,0 +1,43 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +name: sftp +description: 'Behavior test for SFTP' + +runs: + using: "composite" + steps: + - name: Setup sftp + shell: bash + run: | + mkdir -p target/ssh + ssh-keygen -t rsa -b 4096 -f target/ssh/id_rsa -q -N "" < /dev/null + docker run \ + -v `pwd`/target/ssh/id_rsa.pub:/home/foo/.ssh/keys/id_rsa.pub:ro \ + --ulimit nofile=65536:65536 \ + -p 2222:22 -d atmoz/sftp \ + foo::::upload + - name: Setup + shell: bash + run: | + cat << EOF >> $GITHUB_ENV + OPENDAL_SFTP_ENDPOINT=ssh://127.0.0.1:2222 + OPENDAL_SFTP_ROOT=/upload/sftp_test/ + OPENDAL_SFTP_USER=foo + OPENDAL_SFTP_KEY=${{ github.workspace }}/target/ssh/id_rsa + OPENDAL_SFTP_KNOWN_HOSTS_STRATEGY=accept + EOF diff --git a/.github/workflows/service_test_sftp.yml b/.github/workflows/service_test_sftp.yml index 2baf7fd0094d..e69de29bb2d1 100644 --- a/.github/workflows/service_test_sftp.yml +++ b/.github/workflows/service_test_sftp.yml @@ -1,102 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -name: Service Test Sftp - -on: - push: - branches: - - main - pull_request: - branches: - - main - paths: - - "core/src/**" - - "core/tests/**" - - "!core/src/docs/**" - - "!core/src/services/**" - - "core/src/services/sftp/**" - - ".github/workflows/service_test_sftp.yml" - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} - cancel-in-progress: true - -jobs: - sftp-test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Setup sftp - run: | - mkdir -p target/ssh - ssh-keygen -t rsa -b 4096 -f target/ssh/id_rsa -q -N "" < /dev/null - docker run \ - -v `pwd`/target/ssh/id_rsa.pub:/home/foo/.ssh/keys/id_rsa.pub:ro \ - --ulimit nofile=65536:65536 \ - -p 2222:22 -d atmoz/sftp \ - foo::::upload - - name: Setup Rust toolchain - uses: ./.github/actions/setup - with: - need-nextest: true - - name: Test - shell: bash - timeout-minutes: 10 - working-directory: core - run: cargo nextest run behavior --features tests,services-sftp - env: - OPENDAL_TEST: sftp - OPENDAL_SFTP_ENDPOINT: ssh://127.0.0.1:2222 - OPENDAL_SFTP_ROOT: /upload/sftp_test/ - OPENDAL_SFTP_USER: foo - OPENDAL_SFTP_KEY: ${{ github.workspace }}/target/ssh/id_rsa - OPENDAL_SFTP_KNOWN_HOSTS_STRATEGY: accept - - sftp-test-default-root: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Setup sftp - run: | - mkdir -p target/ssh - ssh-keygen -t rsa -b 4096 -f target/ssh/id_rsa -q -N "" < /dev/null - tmpScript="$(mktemp)" - echo "sed -i -e 's#ForceCommand internal-sftp#ForceCommand internal-sftp -d /upload#' /etc/ssh/sshd_config" > "$tmpScript" - chmod +x "$tmpScript" - docker run \ - -v "$tmpScript:/etc/sftp.d/change_root_dir" \ - -v `pwd`/target/ssh/id_rsa.pub:/home/foo/.ssh/keys/id_rsa.pub:ro \ - --ulimit nofile=65536:65536 \ - -p 2222:22 -d atmoz/sftp \ - foo::::upload - - name: Setup Rust toolchain - uses: ./.github/actions/setup - with: - need-nextest: true - - name: Test - shell: bash - timeout-minutes: 10 - working-directory: core - run: cargo nextest run behavior --features tests,services-sftp - env: - OPENDAL_TEST: sftp - OPENDAL_SFTP_ENDPOINT: ssh://127.0.0.1:2222 - OPENDAL_SFTP_USER: foo - OPENDAL_SFTP_KEY: ${{ github.workspace }}/target/ssh/id_rsa - OPENDAL_SFTP_KNOWN_HOSTS_STRATEGY: accept - OPENDAL_DISABLE_RANDOM_ROOT: true From 3cf4a1f37575adc0c850b3976ed7f0cf5d0fbb6b Mon Sep 17 00:00:00 2001 From: suyanhanx Date: Mon, 30 Oct 2023 23:31:06 +0800 Subject: [PATCH 2/2] polish job name Signed-off-by: suyanhanx --- .../{sftp-default-root => sftp_with_default_root}/action.yml | 2 +- .github/workflows/service_test_sftp.yml | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename .github/services/sftp/{sftp-default-root => sftp_with_default_root}/action.yml (98%) delete mode 100644 .github/workflows/service_test_sftp.yml diff --git a/.github/services/sftp/sftp-default-root/action.yml b/.github/services/sftp/sftp_with_default_root/action.yml similarity index 98% rename from .github/services/sftp/sftp-default-root/action.yml rename to .github/services/sftp/sftp_with_default_root/action.yml index 19f7c9a0a3de..a676f67a7bcf 100644 --- a/.github/services/sftp/sftp-default-root/action.yml +++ b/.github/services/sftp/sftp_with_default_root/action.yml @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -name: sftp-default-root +name: sftp_with_default_root description: 'Behavior test for SFTP with default root' runs: diff --git a/.github/workflows/service_test_sftp.yml b/.github/workflows/service_test_sftp.yml deleted file mode 100644 index e69de29bb2d1..000000000000