|
| 1 | +name: Test changes |
| 2 | + |
| 3 | +on: pull_request |
| 4 | +# push: |
| 5 | +# branches: |
| 6 | +# - master |
| 7 | + |
| 8 | +jobs: |
| 9 | + install-and-build: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + outputs: |
| 12 | + jsfileschanged: ${{ steps.checkout.outputs.jsfileschanged }} |
| 13 | + steps: |
| 14 | + - name: "Checkout Repository" |
| 15 | + uses: actions/checkout@v3 |
| 16 | + - uses: ./.github/actions/prepare |
| 17 | + with: |
| 18 | + loadprbuild: false |
| 19 | + |
| 20 | + # count changed js files (diff to base branch) |
| 21 | + - name: "Count changed JS-Files" |
| 22 | + id: checkout |
| 23 | + run: | |
| 24 | + git fetch origin $GITHUB_BASE_REF |
| 25 | + git fetch origin $GITHUB_HEAD_REF |
| 26 | + echo "Target branch : $GITHUB_BASE_REF" |
| 27 | + git checkout -f $GITHUB_HEAD_REF |
| 28 | + git checkout -f $GITHUB_BASE_REF |
| 29 | + git diff --name-only $GITHUB_HEAD_REF -- |
| 30 | + echo '::set-output name=jsfileschanged::'$(git diff --name-only $GITHUB_HEAD_REF -- | grep '^js/*' | wc -l) |
| 31 | + echo 'Num js files changed='$(git diff --name-only $GITHUB_HEAD_REF -- | grep '^js/*' | wc -l) |
| 32 | + git checkout $GITHUB_HEAD_REF |
| 33 | +
|
| 34 | + - name: "Build Project (PR version)" |
| 35 | + run: | |
| 36 | + npm run build |
| 37 | + if: steps.checkout.outputs.jsfileschanged > 0 |
| 38 | + |
| 39 | + - name: "Save built js-files" |
| 40 | + uses: actions/upload-artifact@v3 |
| 41 | + with: |
| 42 | + name: pr-build |
| 43 | + if-no-files-found: error |
| 44 | + path: | |
| 45 | + ./py/visdom/static/js/main.js |
| 46 | + ./py/visdom/static/js/main.js.map |
| 47 | +
|
| 48 | +
|
| 49 | + visual-regression-test-init: |
| 50 | + runs-on: ubuntu-latest |
| 51 | + needs: install-and-build |
| 52 | + steps: |
| 53 | + |
| 54 | + - name: "Checkout Repository" |
| 55 | + uses: actions/checkout@v3 |
| 56 | + - uses: ./.github/actions/prepare |
| 57 | + with: |
| 58 | + usebasebranch: true |
| 59 | + |
| 60 | + - name: Cypress test:init |
| 61 | + uses: cypress-io/github-action@v2 |
| 62 | + with: |
| 63 | + install: false |
| 64 | + start: python3 py/visdom/server.py -port 8098 -env_path /tmp |
| 65 | + wait-on: 'http://localhost:8098' |
| 66 | + spec: cypress/integration/*.init.js |
| 67 | + |
| 68 | + - uses: actions/upload-artifact@v2 |
| 69 | + with: |
| 70 | + name: cypress-init-screenshots |
| 71 | + path: cypress/screenshots_init |
| 72 | + |
| 73 | + |
| 74 | + visual-regression-test: |
| 75 | + runs-on: ubuntu-latest |
| 76 | + needs: visual-regression-test-init |
| 77 | + steps: |
| 78 | + - name: "Checkout Repository" |
| 79 | + uses: actions/checkout@v3 |
| 80 | + - uses: ./.github/actions/prepare |
| 81 | + |
| 82 | + - uses: actions/download-artifact@v2 |
| 83 | + with: |
| 84 | + name: cypress-init-screenshots |
| 85 | + path: cypress/screenshots_init |
| 86 | + |
| 87 | + - name: Cypress test:visual |
| 88 | + uses: cypress-io/github-action@v2 |
| 89 | + with: |
| 90 | + install: false |
| 91 | + start: python3 py/visdom/server.py -port 8098 -env_path /tmp |
| 92 | + wait-on: 'http://localhost:8098' |
| 93 | + spec: cypress/integration/screenshots.js |
| 94 | + |
| 95 | + - uses: actions/upload-artifact@v2 |
| 96 | + if: failure() |
| 97 | + with: |
| 98 | + name: cypress-screenshots-visual |
| 99 | + path: cypress/screenshots |
| 100 | + |
| 101 | + funcitonal-test: |
| 102 | + runs-on: ubuntu-latest |
| 103 | + needs: install-and-build |
| 104 | + steps: |
| 105 | + - name: "Checkout Repository" |
| 106 | + uses: actions/checkout@v3 |
| 107 | + - uses: ./.github/actions/prepare |
| 108 | + |
| 109 | + - name: Cypress test |
| 110 | + uses: cypress-io/github-action@v2 |
| 111 | + with: |
| 112 | + install: false |
| 113 | + start: python3 py/visdom/server.py -port 8098 -env_path /tmp |
| 114 | + wait-on: 'http://localhost:8098' |
| 115 | + config: ignoreTestFiles=screenshots.* |
| 116 | + |
| 117 | + - uses: actions/upload-artifact@v2 |
| 118 | + if: failure() |
| 119 | + with: |
| 120 | + name: cypress-screenshots-functional |
| 121 | + path: cypress/screenshots |
| 122 | + |
0 commit comments