Skip to content

Commit

Permalink
Merge pull request #148 from PaddleCV-SIG/ci
Browse files Browse the repository at this point in the history
update(ci)
  • Loading branch information
linhandev authored Jan 18, 2023
2 parents c95f7d9 + 993f1d9 commit df616d7
Showing 1 changed file with 38 additions and 113 deletions.
151 changes: 38 additions & 113 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ name: E2E Tests
on:
workflow_call:
workflow_dispatch:
# workflow_run:
# workflows: ["Build PaddleLabel package"]
# branches: [develop]
# types:
# - completed
workflow_run:
workflows: ["Build PaddleLabel package"]
branches: [develop]
types:
- completed
schedule:
- cron: "0 12 * * *"

jobs:
e2e_test:
runs-on: ${{ matrix.os }}
# continue-on-error: true
timeout-minutes: 40
defaults:
run:
Expand All @@ -23,19 +22,16 @@ jobs:
matrix:
node-version: ["19.x"]

python-version: ["3.11", "3.10", "3.9", "3.8"]
# python-version: ["3.11", "3.10", "3.9", "3.8"]
os: [ubuntu-latest, windows-latest, macos-latest]

# python-version: ["3.11"]
python-version: ["3.11"]
# os: [windows-latest, ubuntu-latest, macos-latest]
# os: [ubuntu-latest]

fail-fast: false

steps:
# - name: Checkout backend
# uses: actions/checkout@v3

- name: Setup mamba env ${{ matrix.python-version }}
uses: mamba-org/provision-with-micromamba@main
with:
Expand All @@ -46,43 +42,33 @@ jobs:
cache-env: true
channels: conda-forge

# - name: Download PaddleLabel whl package
# uses: dawidd6/action-download-artifact@v2
# id: download_whl
# with:
# github_token: ${{secrets.GITHUB_TOKEN}}
# workflow: build.yml
# workflow_conclusion: success
# name: PaddleLabel_built_package
# search_artifacts: true
# path: ../

- name: Download PaddleLabel whl package
run: |
curl -LO https://nightly.link/PaddleCV-SIG/PaddleLabel/workflows/build/develop/PaddleLabel_built_package.zip
pwd
ls
unzip PaddleLabel_built_package.zip
- name: Parallel - download 3rd party tests and install paddlelabel
run: |
echo ${{ steps.download_whl.outputs }}
{
mkdir -p ~/测试路径/3rd_party/
cd ~/测试路径/3rd_party/
curl -LO https://github.com/linhandev/static/releases/download/PaddleLabel%E7%9B%B8%E5%85%B3/paddlelabel_3rd_party_tests.zip
echo ----------------------------------
ls
unzip -q paddlelabel_3rd_party_tests.zip
pwd
ls
} &
bgid=$!
echo $bgid
# download latest build
curl -LO https://nightly.link/PaddleCV-SIG/PaddleLabel/workflows/build/develop/PaddleLabel_built_package.zip
unzip PaddleLabel_built_package.zip
# install latest build
echo ========================================================
pip uninstall paddlelabel -y
echo ========================================================
pwd
ls
pip install paddlelabel-*-py3-none-any.whl
wait
# wait for bg job
wait $bgid
res=$?
ls ~/测试路径/3rd_party/
if [ $res -ne 0 ]
Expand All @@ -96,48 +82,21 @@ jobs:
repository: PaddleCV-SIG/PaddleLabel-Frontend
ref: paddlelablOcr

- name: Setup node env
uses: actions/setup-node@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- name: Cache yarn dependencies
uses: actions/cache@v3
id: yarn-cache
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
**/node_modules
~/.cache/Cypress
~/AppData/Local/Cypress/Cache
~/Library/Caches/Cypress
key: cypress-yarn-cache-${{ matrix.node-version }}-${{ matrix.os }}-${{ hashFiles('./cypress/yarn.lock') }}

- name: Install packages
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: |
cd cypress
yarn
# yarn add typescript
# https://nightly.link/PaddleCV-SIG/PaddleLabel/workflows/build/develop/PaddleLabel_built_package.zip
- name: Download last run screenshots
uses: dawidd6/action-download-artifact@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: cypress.yml
workflow_conclusion: failure
name: Cypress_test_logs_${{ matrix.os }}_${{ matrix.python-version }}
# search_artifacts: true
path: ../
if_no_artifact_found: ignore

- name: Get failed tests, run them first later
if: always()
id: test_order
run: |
cd ..
Expand All @@ -146,53 +105,28 @@ jobs:
tar -xvf Cypress_test_logs_${{ matrix.os }}_${{ matrix.python-version }}.tar.gz
fi
cd -
echo "======"
ls ../
echo "======"
python cypress/order_tests.py > test_order
cat test_order
echo "tests=$(cat test_order)" >> $GITHUB_OUTPUT
python -c "import platform; print(platform.system().lower())"
- name: Run test
id: test
run: |
# HOME=~/测试路径/ paddlelabel --debug --port 1111 --lan 2>&1 | tee ../paddlelabel.log &
# HOME=~/测试路径/ paddlelabel --debug --port 1111 --lan
HOME=~/测试路径/ paddlelabel --debug --port 1111 --lan 2>&1 | tee ../paddlelabel.log &
cd cypress
time npx wait-port -t 40000 1111
# Xvfb :99 &
# https://docs.cypress.io/guides/continuous-integration/introduction#Xvfb
# Xvfb -screen 0 1024x768x24 :99 &
# DISPLAY=:99 npx cypress run \ ...
# bgpid=$(jobs -l | grep cypress | awk '{print $2}')
echo ${{ steps.test_order.outputs.tests }}
python order_tests.py
pwd
ls
echo "tests=$(python cypress/order_tests.py)" >> $GITHUB_OUTPUT
npx cypress run \
--browser chrome \
--config baseUrl=http://localhost:1111 \
--env os=${{ matrix.os }} \
--spec $(python order_tests.py)
# --spec ${{ steps.test_order.outputs.tests }}
# --spec e2e/6_Doc_Links.cy.ts
- name: Run tests
uses: cypress-io/github-action@v5
id: test
with:
working-directory: ./cypress
browser: chrome
config: baseUrl=http://localhost:1111
env: os=${{ matrix.os }}
spec: ${{ steps.test_order.outputs.tests }}
wait-on: "http://localhost:1111"
wait-on-timeout: 40
start-windows: yarn run test:win
start: yarn run test:unix

- name: Backend logs, cypress screenshots
if: always() && steps.test.outcome == 'failure'
if: failure()
run: |
mkdir -p ./cypress/cypress/
cp ../paddlelabel.log ./cypress/cypress/
echo ============= paddlelabel.log ==============
cat ./cypress/cypress/paddlelabel.log
echo ============= paddlelabel.log ==============
cd ./cypress/cypress/
tar_name=Cypress_test_logs_${{ matrix.os }}_${{ matrix.python-version }}.tar.gz
tar czvf $tar_name *
Expand All @@ -201,17 +135,8 @@ jobs:
curl --upload-file "$tar_name" "https://transfer.sh/$tar_name"
# pip install transfersh-cli
# transfersh
pwd
echo "++++"
ls
echo "++++"
- name: Upload run logs
if: always() && steps.test.outcome == 'failure'
if: failure()
uses: actions/upload-artifact@v3
with:
name: Cypress_test_logs_${{ matrix.os }}_${{ matrix.python-version }}
Expand Down

0 comments on commit df616d7

Please sign in to comment.