代码拉取完成,页面将自动刷新
name: Test and Release
on: push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }}
AWS_ROLE: ${{ secrets.AWS_ROLE }}
WEBAPP_STACK_NAME: ${{ secrets.WEBAPP_STACK_NAME }}
permissions:
id-token: write
contents: write
issues: write
jobs:
test-and-release:
runs-on: ubuntu-22.04
environment: production
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
- uses: actions/setup-node@v4
with:
node-version: "20.x"
cache: "npm"
- name: Cache AWS CLI (Linux)
id: cache-aws-cli
uses: actions/cache@v4
with:
path: aws/
key: cache-aws-cli
- name: Install AWS
if: steps.cache-aws-cli.outputs.cache-hit != 'true'
run: |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip -q awscliv2.zip
sudo ./aws/install --update
- name: configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.AWS_ROLE }}
role-session-name: web-app-ci
aws-region: ${{ env.AWS_REGION }}
- name: Install dependencies
run: npm ci --no-audit
- name: Get web app configuration
run: node .github/workflows/web-app-config.js >> $GITHUB_ENV
- name: Install playwright
run: npx playwright install
- name: Compile TypeScript
run: npx tsc
- name: Check source code with eslint
run: |
npx eslint ./
- name: Check if source code is properly formatted
run: npx prettier -c ./
- name: Run unit tests
run: npm test
- name: Build
env:
PUBLIC_VERSION: ${{ github.sha }}
run: npm run build
- uses: actions/upload-artifact@v4
if: always()
with:
if-no-files-found: error
name: asset-tracker-cloud-app-aws-${{ github.sha }}
path: build
- name: Run end-to-end tests
run: npm run test:e2e
- name: Cleanup test artifacts
if: ${{ failure() }}
run: |
aws iot delete-thing --thing-name `cat test-session/asset.json | jq -r '.thingName'`
aws iot delete-thing --thing-name `cat test-session/asset-no-gnss.json | jq -r '.thingName'`
- name: Cleanup old assets
run: npx tsx e2e-tests/clean-up/cleanOldAssets.ts
- uses: actions/upload-artifact@v4
if: always()
with:
if-no-files-found: error
name: playwright-artifacts-${{ github.sha }}
path: |
server.log
test-session
- name: Semantic release
continue-on-error: true
run: npx semantic-release
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。