Data structure 244 #42
This file contains hidden or 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: autofix.ci | |
| on: | |
| pull_request: | |
| branches: ['main'] | |
| permissions: | |
| contents: read | |
| jobs: | |
| autofix: | |
| runs-on: ubuntu-latest | |
| env: | |
| GITHUB_COMMIT_MESSAGE: '${{ github.event.head_commit.message }}' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: ${{ github.event.pull_request.head.repo.full_name }} | |
| ref: ${{ github.event.pull_request.head.ref }} | |
| - name: Setup node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: '.node_version' | |
| - name: Install node dependencies | |
| run: npm ci | |
| - name: Run Prettier | |
| run: npx prettier --write . | |
| - name: Run autofix | |
| uses: autofix-ci/action@635ffb0c9798bd160680f18fd73371e355b85f27 | |
| test: | |
| runs-on: ubuntu-latest | |
| needs: autofix # Remove this line if you want to run tests in parallel | |
| env: | |
| GITHUB_COMMIT_MESSAGE: '${{ github.event.head_commit.message }}' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: ${{ github.event.pull_request.head.repo.full_name }} | |
| ref: ${{ github.event.pull_request.head.ref }} | |
| - name: Setup node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: '.node_version' | |
| - name: Install node dependencies | |
| run: npm ci | |
| - name: Expose git-specific information to the Vite environment | |
| env: | |
| ENV_FILE: 'env/.env.git.local' | |
| run: | | |
| escape_quotes() { | |
| input="$1" | |
| input="${input//\'/\'}" | |
| input="${input//\"/\\\"}" | |
| echo "$input" | |
| } | |
| echo "------" | |
| echo "# DO NOT EDIT THIS FILE IT IS AUTOMATICALLY GENERATED" > $ENV_FILE | |
| if test -z "${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG }}" | |
| then | |
| echo "VITE_PROJECT_NAME = unknown" >> $ENV_FILE | |
| VITE_PROJECT_NAME='unknown' | |
| else | |
| echo "VITE_PROJECT_NAME = ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG }}" >> $ENV_FILE | |
| VITE_PROJECT_NAME='${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG }}' | |
| fi | |
| if test -z "${{ env.GITHUB_SHA_SHORT }}" | |
| then | |
| echo "VITE_GIT_HASH = x0x0x0x0" >> $ENV_FILE | |
| VITE_GIT_HASH='x0x0x0x0' | |
| else | |
| echo "VITE_GIT_HASH = ${{ env.GITHUB_SHA_SHORT }}" >> $ENV_FILE | |
| VITE_GIT_HASH='${{ env.GITHUB_SHA_SHORT }}' | |
| fi | |
| if test -z "${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG }}" | |
| then | |
| echo "VITE_GIT_OWNER = unknown_owner" >> $ENV_FILE | |
| VITE_GIT_OWNER='unknown_owner' | |
| else | |
| echo "VITE_GIT_OWNER = ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG }}" >> $ENV_FILE | |
| VITE_GIT_OWNER='${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG }}' | |
| fi | |
| if test -z "${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG }}" | |
| then | |
| echo "VITE_GIT_REPO_NAME = unknown_repo" >> $ENV_FILE | |
| VITE_GIT_REPO_NAME='unknown_repo' | |
| else | |
| echo "VITE_GIT_REPO_NAME = ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG }}" >> $ENV_FILE | |
| VITE_GIT_REPO_NAME='${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG }}' | |
| fi | |
| if test -z "${{ env.GITHUB_REF_SLUG }}" | |
| then | |
| echo "VITE_GIT_BRANCH_NAME = unknown_branch" >> $ENV_FILE | |
| VITE_GIT_BRANCH_NAME='unknown_branch' | |
| else | |
| echo "VITE_GIT_BRANCH_NAME = ${{ env.GITHUB_REF_SLUG }}" >> $ENV_FILE | |
| VITE_GIT_BRANCH_NAME='${{ env.GITHUB_REF_SLUG }}' | |
| fi | |
| if test -z "${{ github.event.head_commit.message }}" | |
| then | |
| echo "VITE_GIT_LAST_MSG = (no commit message)" >> $ENV_FILE | |
| VITE_GIT_LAST_MSG='(no commit message)' | |
| else | |
| echo "VITE_GIT_LAST_MSG = $GITHUB_COMMIT_MESSAGE" >> $ENV_FILE | |
| VITE_GIT_LAST_MSG="$GITHUB_COMMIT_MESSAGE" | |
| fi | |
| echo "VITE_DEPLOY_BASE_PATH = '/${VITE_GIT_OWNER}/${VITE_GIT_REPO_NAME}/${VITE_GIT_BRANCH_NAME}/'" >> $ENV_FILE | |
| CODENAME=$(node scripts/codenamize.cjs "/${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG }}/${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG }}/${{ env.GITHUB_REF_SLUG }}") | |
| echo "VITE_CODE_NAME = ${CODENAME}" >> $ENV_FILE | |
| cat $ENV_FILE | |
| - name: create mock deploy file | |
| env: | |
| DEPLOY_ENV_FILE: 'env/.env.local' | |
| run: | | |
| echo "VITE_FIREBASE_APIKEY=mock-api-key" > $DEPLOY_ENV_FILE | |
| echo "VITE_FIREBASE_AUTHDOMAIN=mock-auth-domain" >> $DEPLOY_ENV_FILE | |
| echo "VITE_FIREBASE_PROJECTID=mock-project-id" >> $DEPLOY_ENV_FILE | |
| echo "VITE_FIREBASE_STORAGEBUCKET=mock-storage-bucket" >> $DEPLOY_ENV_FILE | |
| echo "VITE_FIREBASE_MESSAGINGSENDERID=mock-messaging-sender-id" >> $DEPLOY_ENV_FILE | |
| echo "VITE_FIREBASE_APPID=mock-app-id" >> $DEPLOY_ENV_FILE | |
| cat $DEPLOY_ENV_FILE | |
| - name: create mock deploy.local file | |
| env: | |
| DEPLOY_ENV_FILE: 'env/.env.deploy.local' | |
| run: | | |
| echo "VITE_DEPLOY_BASE_PATH = '/mock-owner/mock-repo/mock-branch/'" > $DEPLOY_ENV_FILE | |
| echo "VITE_DEPLOY_URL = 'https://mock-deploy-host/mock-owner/mock-repo/mock-branch/'" >> $DEPLOY_ENV_FILE | |
| echo 'VITE_CODE_NAME_DEPLOY_URL = "https://mock-deploy-host/e/mock-code-name"' >> $DEPLOY_ENV_FILE | |
| cat $DEPLOY_ENV_FILE | |
| - name: Load the github dotenv file | |
| id: dotenv_github | |
| uses: falti/dotenv-action@v1.1 | |
| with: | |
| path: 'env/.env.git.local' | |
| - name: Load the general config dotenv file | |
| id: dotenv_config | |
| uses: falti/dotenv-action@v1.1 | |
| with: | |
| path: './env/.env.local' | |
| - name: Load the deploy general config dotenv file | |
| id: dotenv_deploy | |
| uses: falti/dotenv-action@v1.1 | |
| with: | |
| path: './env/.env.deploy.local' | |
| - name: Run tests | |
| id: run-tests | |
| run: npm run test |