Skip to content

Commit abb3520

Browse files
committed
debug: ci mock server on windows
1 parent 00ebb0d commit abb3520

File tree

1 file changed

+9
-111
lines changed

1 file changed

+9
-111
lines changed

.github/workflows/ci-test.yml

Lines changed: 9 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,13 @@
11
on: [push]
22
name: Run Test Cases
33
jobs:
4-
test:
5-
strategy:
6-
fail-fast: false
7-
max-parallel: 1
8-
matrix:
9-
python_version: ['2.7', '3.4', '3.5', '3.6', '3.7', '3.8', '3.9']
10-
runs-on: ubuntu-20.04
11-
steps:
12-
- name: Checkout repo
13-
uses: actions/checkout@v2
14-
with:
15-
ref: ${{ github.ref }}
16-
- name: Setup miniconda
17-
uses: conda-incubator/setup-miniconda@v2
18-
with:
19-
auto-update-conda: true
20-
channels: conda-forge
21-
python-version: ${{ matrix.python_version }}
22-
activate-environment: qiniu-sdk
23-
auto-activate-base: false
24-
- name: Setup pip
25-
shell: bash -l {0}
26-
env:
27-
PYTHON_VERSION: ${{ matrix.python_version }}
28-
PIP_BOOTSTRAP_SCRIPT_PREFIX: https://bootstrap.pypa.io/pip
29-
run: |
30-
MAJOR=$(echo "$PYTHON_VERSION" | cut -d'.' -f1)
31-
MINOR=$(echo "$PYTHON_VERSION" | cut -d'.' -f2)
32-
# reinstall pip by some python(<3.7) not compatible
33-
if ! [[ $MAJOR -ge 3 && $MINOR -ge 7 ]]; then
34-
cd /tmp
35-
wget -qLO get-pip.py "$PIP_BOOTSTRAP_SCRIPT_PREFIX/$MAJOR.$MINOR/get-pip.py"
36-
python get-pip.py --user
37-
fi
38-
- name: Setup mock server
39-
shell: bash -el {0}
40-
run: |
41-
conda create -y -n mock-server python=3.10
42-
conda activate mock-server
43-
python3 --version
44-
nohup python3 tests/mock_server/main.py --port 9000 > py-mock-server.log &
45-
echo $! > mock-server.pid
46-
conda deactivate
47-
- name: Install dependencies
48-
shell: bash -l {0}
49-
run: |
50-
python -m pip install --upgrade pip
51-
python -m pip install -I -e ".[dev]"
52-
- name: Run cases
53-
shell: bash -el {0}
54-
env:
55-
QINIU_ACCESS_KEY: ${{ secrets.QINIU_ACCESS_KEY }}
56-
QINIU_SECRET_KEY: ${{ secrets.QINIU_SECRET_KEY }}
57-
QINIU_TEST_BUCKET: ${{ secrets.QINIU_TEST_BUCKET }}
58-
QINIU_TEST_NO_ACC_BUCKET: ${{ secrets.QINIU_TEST_NO_ACC_BUCKET }}
59-
QINIU_TEST_DOMAIN: ${{ secrets.QINIU_TEST_DOMAIN }}
60-
QINIU_UPLOAD_CALLBACK_URL: ${{secrets.QINIU_UPLOAD_CALLBACK_URL}}
61-
QINIU_TEST_ENV: "travis"
62-
MOCK_SERVER_ADDRESS: "http://127.0.0.1:9000"
63-
run: |
64-
flake8 --show-source --max-line-length=160 ./qiniu
65-
python -m pytest ./test_qiniu.py tests --cov qiniu --cov-report=xml
66-
- name: Post Setup mock server
67-
if: ${{ always() }}
68-
shell: bash
69-
run: |
70-
set +e
71-
cat mock-server.pid | xargs kill
72-
rm mock-server.pid
73-
- name: Print mock server log
74-
if: ${{ failure() }}
75-
run: |
76-
cat py-mock-server.log
77-
- name: Upload results to Codecov
78-
uses: codecov/codecov-action@v4
79-
with:
80-
token: ${{ secrets.CODECOV_TOKEN }}
814
test-win:
825
strategy:
836
fail-fast: false
847
max-parallel: 1
858
matrix:
86-
python_version: ['2.7', '3.5', '3.9']
9+
python_version: ['3.8']
8710
runs-on: windows-2019
88-
# make sure only one test running,
89-
# remove this when cases could run in parallel.
90-
needs: test
9111
steps:
9212
- name: Checkout repo
9313
uses: actions/checkout@v2
@@ -106,39 +26,18 @@ jobs:
10626
conda create -y -n mock-server python=3.10
10727
conda activate mock-server
10828
python --version
109-
$mocksrvp = Start-Process -FilePath "python" -ArgumentList "tests/mock_server/main.py", "--port", "9000" -PassThru -NoNewWindow -RedirectStandardOutput "py-mock-server.log"
29+
$mocksrvp = Start-Process
30+
-FilePath "python"
31+
-ArgumentList "tests/mock_server/main.py", "--port", "9000"
32+
-PassThru -NoNewWindow
33+
-RedirectStandardOutput "py-mock-server.log"
34+
-RedirectStandardError "py-mock-server.log"
11035
$mocksrvp.Id | Out-File -FilePath "mock-server.pid"
11136
Write-Host -Object $mocksrvp
11237
conda deactivate
113-
- name: Setup pip
114-
env:
115-
PYTHON_VERSION: ${{ matrix.python_version }}
116-
PIP_BOOTSTRAP_SCRIPT_PREFIX: https://bootstrap.pypa.io/pip
117-
run: |
118-
# reinstall pip by some python(<3.7) not compatible
119-
$pyversion = [Version]"$ENV:PYTHON_VERSION"
120-
if ($pyversion -lt [Version]"3.7") {
121-
Invoke-WebRequest "$ENV:PIP_BOOTSTRAP_SCRIPT_PREFIX/$($pyversion.Major).$($pyversion.Minor)/get-pip.py" -OutFile "$ENV:TEMP\get-pip.py"
122-
python $ENV:TEMP\get-pip.py --user
123-
Remove-Item -Path "$ENV:TEMP\get-pip.py"
124-
}
125-
- name: Install dependencies
126-
run: |
127-
python -m pip install --upgrade pip
128-
python -m pip install -I -e ".[dev]"
129-
- name: Run cases
130-
env:
131-
QINIU_ACCESS_KEY: ${{ secrets.QINIU_ACCESS_KEY }}
132-
QINIU_SECRET_KEY: ${{ secrets.QINIU_SECRET_KEY }}
133-
QINIU_TEST_BUCKET: ${{ secrets.QINIU_TEST_BUCKET }}
134-
QINIU_TEST_NO_ACC_BUCKET: ${{ secrets.QINIU_TEST_NO_ACC_BUCKET }}
135-
QINIU_TEST_DOMAIN: ${{ secrets.QINIU_TEST_DOMAIN }}
136-
QINIU_UPLOAD_CALLBACK_URL: ${{secrets.QINIU_UPLOAD_CALLBACK_URL}}
137-
QINIU_TEST_ENV: "github"
138-
MOCK_SERVER_ADDRESS: "http://127.0.0.1:9000"
139-
PYTHONPATH: "$PYTHONPATH:."
38+
- name: Test mock server
14039
run: |
141-
python -m pytest ./test_qiniu.py tests --cov qiniu --cov-report=xml
40+
Invoke-WebRequest "http://127.0.0.1:9000/echo?status=200"
14241
- name: Post Setup mock server
14342
if: ${{ always() }}
14443
run: |
@@ -150,7 +49,6 @@ jobs:
15049
Write-Host -Object $_
15150
}
15251
- name: Print mock server log
153-
if: ${{ failure() }}
15452
run: |
15553
Get-Content -Path "py-mock-server.log"
15654
- name: Upload results to Codecov

0 commit comments

Comments
 (0)