Skip to content

Commit 1686edf

Browse files
David HartmannJackUrb
David Hartmann
authored andcommittedApr 28, 2022
github: added process-push workflow
github: fixed wrong jsfileschanged github: fix jsfileschanged Split from "github: removed update-js-build-files (integrated into process-push)" github: fix ci for forked repos & let github-bot push new js files in a seperate job
1 parent bd220dc commit 1686edf

File tree

3 files changed

+198
-0
lines changed

3 files changed

+198
-0
lines changed
 

‎.github/actions/prepare/action.yml

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: 'Prepare Test Dependencies'
2+
description: 'Installs Dependencies & Caches Them'
3+
inputs:
4+
usebasebranch:
5+
description: 'use true for pr version, use false for base version'
6+
required: true
7+
default: false
8+
loadprbuild:
9+
description: 'use true to load the resulting build files (from previous step)'
10+
required: true
11+
default: true
12+
13+
runs:
14+
using: "composite"
15+
steps:
16+
- name: "Setup Node"
17+
uses: actions/setup-node@v2
18+
with:
19+
node-version: '16'
20+
21+
- name: "Action Settings"
22+
run: |
23+
echo usebasebranch=${{ inputs.usebasebranch }}
24+
echo loadprbuild=${{ inputs.loadprbuild }}
25+
shell: bash
26+
27+
# checkout correct version
28+
- name: "Checkout base branch"
29+
run: |
30+
git fetch origin $GITHUB_BASE_REF
31+
git checkout -f $GITHUB_BASE_REF
32+
shell: bash
33+
if: ${{ inputs.usebasebranch == 'true' }}
34+
35+
36+
# now cache pip
37+
- uses: actions/cache@v3
38+
id: cache-pip
39+
with:
40+
path: ~/.cache/pip
41+
key: ${{ runner.os }}-pip-${{ hashFiles('**/test-requirements.txt') }}
42+
restore-keys: |
43+
${{ runner.os }}-pip-
44+
- name: "Install Pip Dependencies"
45+
shell: bash
46+
run: |
47+
pip3 install -r test-requirements.txt
48+
pip3 install -e .
49+
50+
# now compile the new version
51+
- uses: actions/cache@v3
52+
id: cache-npm
53+
with:
54+
path: |
55+
"**/node_modules"
56+
"/home/runner/.cache"
57+
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
58+
- name: "Install npm Dependencies"
59+
shell: bash
60+
run: |
61+
npm install
62+
63+
# load artifacts from previous runs
64+
- name: "Load built js-files"
65+
uses: actions/download-artifact@v3
66+
with:
67+
name: pr-build
68+
path: ./py/visdom/static/js/
69+
if: ${{ inputs.loadprbuild == 'true' }}
70+
71+

‎.github/workflows/process-changes.yml

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
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+

‎test-requirements.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
matplotlib
2+
numpy
3+
av
4+
--extra-index-url https://download.pytorch.org/whl/cpu
5+
torch

0 commit comments

Comments
 (0)