[feat] Add metric to monitor app install shares #1143
Workflow file for this run
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: Gazebo CI | |
on: | |
push: | |
branches: | |
- main | |
- staging | |
pull_request: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
install: | |
name: Install deps | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18.8.0' | |
- name: Cache node_modules | |
id: cache-node-modules | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-gazebo-node-modules | |
with: | |
path: | | |
node_modules | |
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-${{ env.cache-name }}- | |
# - name: Setup Bun | |
# uses: oven-sh/setup-bun@v1 | |
# if: ${{ steps.cache-node-modules.outputs.cache-hit != 'true' }} | |
- name: Install packages | |
if: ${{ steps.cache-node-modules.outputs.cache-hit != 'true' }} | |
run: | | |
npm install | |
lint: | |
name: Run Lint | |
runs-on: ubuntu-latest | |
needs: install | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18.8.0' | |
- name: Cache node_modules | |
id: cache-node-modules | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-gazebo-node-modules | |
with: | |
path: | | |
node_modules | |
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-${{ env.cache-name }}- | |
- name: Run linter | |
run: | | |
npm run lint | |
type-check: | |
name: Run Type Checker | |
runs-on: ubuntu-latest | |
needs: install | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18.8.0' | |
- name: Cache node_modules | |
id: cache-node-modules | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-gazebo-node-modules | |
with: | |
path: | | |
node_modules | |
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-${{ env.cache-name }}- | |
- name: Run TSC | |
run: | | |
npm run type-check | |
codecovstartup: | |
name: Codecov Startup | |
needs: install | |
uses: codecov/gha-workflows/.github/workflows/codecov-startup.yml@v1.2.14 | |
secrets: inherit | |
runner-indexes: | |
runs-on: ubuntu-latest | |
name: Generate runner indexes | |
needs: install | |
env: | |
TEST_SPLIT_NUMBER: 80 | |
outputs: | |
json: ${{ steps.generate-index-list.outputs.json }} | |
test_list_array: ${{ steps.generate-index-list.outputs.test_list_array }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Generate test index list | |
id: generate-index-list | |
run: | | |
shopt -s globstar | |
TEST_LIST=$(ls src/**/*.spec.js src/**/*.test.js src/**/*.spec.jsx src/**/*.spec.ts src/**/*.spec.tsx | jq -R -s -c 'split("\n")[:-1]') | |
TEST_LENGTH=$(echo $TEST_LIST | jq length) | |
MAX_INDEX=$((($TEST_LENGTH/${{ env.TEST_SPLIT_NUMBER }}))) | |
MAX_INDEX=$(($MAX_INDEX < 0 ? 0 : $TEST_LENGTH % ${{ env.TEST_SPLIT_NUMBER }} == 0 ? $MAX_INDEX - 1 : $MAX_INDEX)) | |
INDEX_LIST=$(seq 0 ${MAX_INDEX}) | |
INDEX_JSON=$(jq --null-input --compact-output '. |= [inputs]' <<< ${INDEX_LIST}) | |
echo json=${INDEX_JSON} >> $GITHUB_OUTPUT | |
echo test_list_array=$(echo ${TEST_LIST} | jq -c '[_nwise(${{ env.TEST_SPLIT_NUMBER }})]') >> $GITHUB_OUTPUT | |
test: | |
name: 'Test Runner #${{ matrix.runner-index }}' | |
needs: [install, codecovstartup, runner-indexes] | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
runner-index: ${{ fromjson(needs.runner-indexes.outputs.json) }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18.8.0' | |
- name: Cache node_modules | |
id: cache-node-modules | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-gazebo-node-modules | |
with: | |
path: | | |
node_modules | |
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-${{ env.cache-name }}- | |
- name: Run tests | |
run: | | |
TESTS=$(echo $TEST_LIST | jq -cr 'join(" ")') | |
npm run test:ci -- --maxWorkers=2 $TESTS | |
env: | |
JEST_JUNIT_OUTPUT_DIR: ./reports/junit/ | |
TEST_LIST: ${{ tojson(fromjson(needs.runner-indexes.outputs.test_list_array)[matrix.runner-index]) }} | |
- name: Test Report | |
uses: dorny/test-reporter@v1 | |
if: success() || failure() | |
with: | |
name: JEST Tests | |
path: reports/junit/*.xml | |
reporter: jest-junit | |
- name: Install CLI | |
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }} | |
run: | | |
make test_env.install_cli | |
## Don't upload on forks for now. | |
- name: Upload to Production | |
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }} | |
run: | | |
codecovcli -u ${{ secrets.CODECOV_URL }} do-upload -t ${{ secrets.CODECOV_ORG_TOKEN }} --fail-on-error | |
- name: Upload to Staging | |
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }} | |
run: | | |
codecovcli -u ${{ secrets.CODECOV_STAGING_URL }} do-upload -t ${{ secrets.CODECOV_ORG_TOKEN_STAGING }} --fail-on-error | |
- name: Upload to QA | |
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }} | |
run: | | |
codecovcli -u ${{ secrets.CODECOV_QA_URL }} do-upload -t ${{ secrets.CODECOV_QA_TOKEN }} --fail-on-error | |
- name: Upload to Public QA | |
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }} | |
run: | | |
codecovcli -u ${{ secrets.CODECOV_PUBLIC_QA_URL }} do-upload -t ${{ secrets.CODECOV_PUBLIC_QA_TOKEN }} --fail-on-error | |
storybook: | |
name: Run storybook | |
runs-on: ubuntu-latest | |
needs: install | |
if: ${{ !github.event.pull_request.head.repo.fork && !startsWith(github.ref, 'refs/heads/dependabot') && github.repository_owner == 'codecov' }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18.8.0' | |
- name: Cache node_modules | |
id: cache-node-modules | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-gazebo-node-modules | |
with: | |
path: | | |
node_modules | |
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-${{ env.cache-name }}- | |
- name: Deploy to Chromatic | |
run: | | |
npm run chromatic | |
env: | |
CHROMATIC_PROJECT_TOKEN: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} | |
fossa: | |
name: Run Fossa | |
runs-on: ubuntu-latest | |
needs: install | |
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18.8.0' | |
- name: Run Fossa | |
uses: fossas/fossa-action@v1.3.1 | |
with: | |
api-key: ${{secrets.FOSSA_API_KEY}} | |
build: | |
name: Build App | |
runs-on: ubuntu-latest | |
needs: [install, test] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18.8.0' | |
- name: Cache node_modules | |
id: cache-node-modules | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-gazebo-node-modules | |
with: | |
path: | | |
node_modules | |
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-${{ env.cache-name }}- | |
- name: Build React App | |
run: | | |
npm run build | |
build-self-hosted: | |
name: Build Self Hosted Image | |
secrets: inherit | |
if: ${{ !github.event.pull_request.head.repo.fork && github.repository_owner == 'codecov' }} | |
uses: codecov/gha-workflows/.github/workflows/self-hosted.yml@v1.2.14 | |
with: | |
repo: ${{ vars.CODECOV_IMAGE_V2 || 'codecov/self-hosted-frontend' }} | |
cache_requirements: false | |
self-hosted: | |
name: Push Self Hosted Image | |
needs: [ build-self-hosted, test ] | |
secrets: inherit | |
if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/main' && github.repository_owner == 'codecov' }} | |
uses: codecov/gha-workflows/.github/workflows/self-hosted.yml@v1.2.14 | |
with: | |
push_rolling: true | |
repo: ${{ vars.CODECOV_IMAGE_V2 || 'codecov/self-hosted-frontend' }} | |
cache_requirements: false |