schedule testing #108
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: schedule testing | |
on: | |
workflow_dispatch: | |
workflow_call: | |
secrets: | |
SOURCE_TREE_PROTECTED_BRANCH_TOKEN: | |
required: true | |
SAUCE_ACCESS_KEY: | |
required: true | |
schedule: | |
- cron: "0 2 * * 3,6" | |
permissions: | |
actions: write | |
contents: write | |
id-token: write | |
env: | |
TEST_URL: https://test-integration-example.fly.dev | |
jobs: | |
static_and_unit_test: | |
name: Static test and unit test | |
if: github.event.action != 'closed' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: latest | |
- name: Cache node_modules | |
id: cache-node-modules | |
uses: actions/cache@v4 | |
with: | |
path: node_modules | |
key: node-modules-${{ hashFiles('package-lock.json') }} | |
- name: Install dependencies | |
run: npm ci | |
- name: Lint test | |
run: npm run ci-lint | |
- name: Unit test | |
run: npm run ci-test | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: lint-output | |
path: lint.log | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: unit-test-output | |
path: ./reporters | |
# functional_test: | |
# name: Functional test | |
# runs-on: ubuntu-latest | |
# env: | |
# SAUCE_USERNAME: sky172839465 | |
# SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} | |
# steps: | |
# - uses: actions/checkout@v4 | |
# - uses: actions/setup-java@v4 | |
# with: | |
# distribution: "temurin" | |
# java-version: "17" | |
# - name: Cache node_modules | |
# id: cache-node-modules | |
# uses: actions/cache@v4 | |
# with: | |
# path: node_modules | |
# key: node-modules-${{ hashFiles('package-lock.json') }} | |
# - name: Install dependencies | |
# run: npm ci | |
# - name: Run functional test on saucelabs | |
# env: | |
# TEST_URL: ${{ env.TEST_URL }} | |
# run: | | |
# echo TEST_URL=$TEST_URL | |
# npm run ci-functional | |
# - name: Generate functional test allure report | |
# run: npm run functional:generate-report | |
# - uses: actions/upload-artifact@v4 | |
# with: | |
# name: functional-test-output | |
# path: ./output | |
# - name: Upload report to GitHub page | |
# if: ${{ always() }} | |
# uses: peaceiris/actions-gh-pages@v3 | |
# with: | |
# github_token: ${{ secrets.GITHUB_TOKEN }} | |
# publish_dir: ./e2e-reports | |
# destination_dir: ${{ github.run_id }} | |
# commit_message: "docs: 🤖 upload schedule report ${{ github.run_id }}" | |
# user_name: "github-actions[bot]" | |
# user_email: "github-actions[bot]@users.noreply.github.com" | |
clean_up: | |
needs: [static_and_unit_test] | |
if: ${{ always() }} | |
name: Clean up | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Cache node_modules | |
id: cache-node-modules | |
uses: actions/cache@v4 | |
with: | |
path: node_modules | |
key: node-modules-${{ hashFiles('package-lock.json') }} | |
- name: Install dependencies | |
run: npm ci | |
- uses: actions/download-artifact@v4 | |
with: | |
name: lint-output | |
- uses: actions/download-artifact@v4 | |
with: | |
name: unit-test-output | |
path: ./reports | |
# - uses: actions/download-artifact@v4 | |
# with: | |
# name: functional-test-output | |
# path: ./output | |
- name: Get report info | |
if: ${{ always() }} | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const { getGHPageInfo } = require('./scripts/ghpage-helper.cjs') | |
const info = await getGHPageInfo({ context }, '${{ github.run_id }}') | |
console.log(info) | |
core.exportVariable('GH_PAGE_URL', info.ghPage) | |
- id: get-date | |
run: | | |
echo "DATE=$(date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_OUTPUT | |
- name: Get build comment | |
if: ${{ always() }} | |
uses: actions/github-script@v7 | |
env: | |
TEST_URL: ${{ env.TEST_URL }} | |
DATE: ${{ steps.get-date.outputs.DATE }} | |
with: | |
script: | | |
const getComment = require('./scripts/get-comment.cjs') | |
const comment = await getComment({ context }) | |
console.log(comment) | |
core.exportVariable('BUILD_COMMENT', comment) | |
result-encoding: string | |
- name: Comment build result to issue | |
uses: peter-evans/create-or-update-comment@v3 | |
with: | |
token: ${{ secrets.SOURCE_TREE_PROTECTED_BRANCH_TOKEN }} | |
comment-id: 1890858131 | |
body: ${{ env.BUILD_COMMENT }} | |
edit-mode: replace | |
- name: Add job summary | |
if: ${{ always() }} | |
run: | | |
echo "${{ env.BUILD_COMMENT }}" >> $GITHUB_STEP_SUMMARY | |
- name: Last check build status | |
if: ${{ always() }} | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
if (process.env.BUILD_COMMENT.includes('❌')) { | |
console.error('Job failed.') | |
process.exit(1) | |
} |