automated tests #7440
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: automated tests | |
on: | |
push: null | |
pull_request: null | |
schedule: | |
- cron: 0 0 * * * | |
jobs: | |
build: | |
outputs: | |
bin_ids: ${{ env.bin_ids }} | |
bins: ${{ env.bins }} | |
clients: ${{ env.clients }} | |
slow: ${{ env.slow }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
submodules: true # Fetch Hugo themes (true OR recursive) | |
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod | |
- name: get package version | |
run: echo "version="`jq -r .version package.json` >> $GITHUB_ENV | |
- name: cancel spurious build on tagged version | |
uses: andymckay/cancel-action@master | |
if: github.event.head_commit.message == env.version && !startsWith(github.ref, | |
'refs/tags/') | |
- name: install python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
cache: pip | |
- name: install python packages | |
run: | | |
python -m pip install --upgrade pip | |
pip install packaging xvfbwrapper | |
pip install -r requirements.txt | |
- name: install node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- name: Cache python/node dependencies | |
id: cache | |
uses: actions/cache@v4 | |
env: | |
cache-name: v3 | |
with: | |
path: | | |
~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('package-lock.json') | |
}}-${{ hashFiles('requirements.txt') }} | |
- name: install node packages | |
run: npm install | |
- name: set slow/legacy/beta flags | |
run: ./util/action-flags | |
env: | |
GITHUB_CONTEXT: ${{ toJson(github) }} | |
- name: get previous test durations | |
run: curl -L | |
https://github.com/retorquere/zotero-better-bibtex/releases/download/builds/durations${{ | |
env.slow }}.json --create-dirs -o test/balance/durations.json | |
- name: balance tests | |
id: balance | |
run: ./util/balance.py --durations test/balance/durations.json --bins test/balance/bins.json | |
--minutes 10 ${{ env.slow }} ${{ env.beta }} ${{ env.legacy }} | |
- name: build ${{ env.beta }} ${{ env.legacy }} | |
run: npm run build | |
env: | |
VERSION_WITH_ISSUE: false | |
- name: publish debug bridge | |
run: ./util/publish-debug-bridge.py | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: store build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build-artifacts | |
path: | | |
xpi/ | |
gen/ | |
test/balance/ | |
retention-days: 1 | |
# site | |
- name: build site | |
uses: peaceiris/actions-hugo@v3 | |
if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/master' || | |
startsWith(github.ref, 'refs/tags/')) }} | |
with: | |
hugo-version: latest | |
extended: true | |
- name: prepare docs for deploy | |
run: npm run docs:deploy | |
if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/master' || | |
startsWith(github.ref, 'refs/tags/')) }} | |
- name: deploy site | |
uses: peaceiris/actions-gh-pages@v4 | |
if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/master' || | |
startsWith(github.ref, 'refs/tags/')) }} | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./site/public | |
test: | |
needs: | |
- build | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
bin: ${{ fromJSON(needs.build.outputs.bin_ids) }} | |
client: ${{ fromJSON(needs.build.outputs.clients) }} | |
worker: [--worker, --no-worker] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: fetch build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: build-artifacts | |
- name: install python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
cache: pip | |
- name: install python packages | |
run: | | |
python -m pip install --upgrade pip | |
pip install packaging xvfbwrapper | |
pip install -r requirements.txt | |
- name: Cache python/node dependencies | |
id: cache | |
uses: actions/cache@v4 | |
env: | |
cache-name: v3 | |
with: | |
path: | | |
~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('package-lock.json') | |
}}-${{ hashFiles('requirements.txt') }} | |
- name: install ${{ matrix.client }} | |
run: | | |
curl -sL https://raw.githubusercontent.com/retorquere/zotero-deb/master/install.sh | sudo bash | |
sudo apt-get update | |
sudo apt-get install ${{ matrix.client }} | |
sudo apt-get install mesa-utils libegl1-mesa xvfb | |
curl -LO https://github.com/jgm/pandoc/releases/download/3.1.11.1/pandoc-3.1.11.1-linux-amd64.tar.gz | |
tar xvzf pandoc-3.1.11.1-linux-amd64.tar.gz | |
sudo mv pandoc-3.1.11.1/bin/pandoc /usr/bin | |
pandoc -v | |
# preserve log hierarchy | |
mkdir stats | |
mkdir .stats | |
mktemp .stats/stats.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX | |
- name: Run tests | |
# continue-on-error: ${{ matrix.client == 'jurism' }} | |
run: ./test/behave --client ${{ matrix.client }} ${{ matrix.worker }} --format | |
ci --bin ${{ matrix.bin }} --bins ${{ needs.build.outputs.bins }} --durations | |
test/stats/durations--${{ matrix.client }}--${{ matrix.bin }}${{ matrix.worker | |
}}.json ${{ needs.build.outputs.slow }} | |
env: | |
PYTHONUNBUFFERED: true | |
- name: save log on failure | |
if: ${{ failure() || cancelled() }} | |
run: | | |
touch ~/.BBTTEST.log | |
cp ~/.BBTTEST.log ~/BBTTEST--${{ matrix.client }}--${{ matrix.bin }}${{ matrix.worker }}.txt | |
cp -r ~/.BBTTEST ~/BBTTEST | |
- name: upload log on failure | |
if: ${{ failure() || cancelled() }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: debug-log--${{ matrix.client }}--${{ matrix.bin }}${{ matrix.worker | |
}} | |
path: | | |
~/BBTTEST*.txt | |
exported/ | |
retention-days: 5 | |
- name: store test artifacts | |
if: matrix.client == 'zotero' && matrix.worker == '--worker' && github.event_name | |
== 'push' && github.ref == 'refs/heads/master' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: test-artifacts--${{ matrix.client }}--${{ matrix.bin }}${{ matrix.worker | |
}} | |
path: ./*/stats/durations* | |
retention-days: 2 | |
# - name: Setup tmate session | |
# if: ${{ failure() }} | |
# uses: mxschmitt/action-tmate@v3 | |
# with: | |
# limit-access-to-actor: true | |
release: | |
if: github.event_name != 'schedule' | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: fetch build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: build-artifacts | |
- name: install python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
cache: pip | |
- name: install python packages | |
run: | | |
python -m pip install --upgrade pip | |
pip install packaging xvfbwrapper | |
pip install -r requirements.txt | |
- name: install node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- name: Cache python/node dependencies | |
id: cache | |
uses: actions/cache@v4 | |
env: | |
cache-name: v3 | |
with: | |
path: | | |
~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('package-lock.json') | |
}}-${{ hashFiles('requirements.txt') }} | |
- name: install node packages | |
run: npm install | |
- run: npm run release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- uses: actions/github-script@v7 | |
continue-on-error: true | |
with: | |
script: | | |
if (process.env.XPI_RELEASED) { | |
github.rest.issues.addLabels({ | |
issue_number: parseInt(process.env.XPI_RELEASED), | |
owner: 'retorquere', | |
repo: 'zotero-better-bibtex', | |
labels: ['awaiting-user-feedback'], | |
}) | |
} | |
durations: | |
if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
needs: | |
- build | |
- test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: install python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
cache: pip | |
- name: install python packages | |
run: | | |
python -m pip install --upgrade pip | |
pip install packaging xvfbwrapper | |
pip install -r requirements.txt | |
- name: fetch test artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: test-artifacts--* | |
merge-multiple: true | |
- name: collect test data | |
run: jq -s add test/stats/durations--*.json > test/stats/durations${{ needs.build.outputs.slow | |
}}.json | |
- name: Store build stats | |
run: | | |
gh release upload builds test/stats/durations${{ needs.build.outputs.slow }}.json --clobber --repo ${{ github.repository }} | |
env: | |
GH_TOKEN: ${{ github.token }} |