rid*_*nsb 10 continuous-integration unit-testing firebase firebase-tools github-actions
我正在尝试在 Github Actinos 上运行测试,但经过多次尝试后我无法做到这一点。
\n\n接收
\n\n\n\n\n错误:firestore:Firestore 模拟器已退出,因为未安装 java,您可以从https://openjdk.java.net/install/安装它
\n
- name: Test\n uses: w9jds/firebase-action@v1.3.1\n env:\n JAVA_HOME: ${{ env.JAVA_HOME }}\n FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}\n GCLOUD_PROJECT: ${{ secrets.nextGCLOUD_PROJECT }}\n PROJECT_ID: ${{ secrets.nextFIREBASE_PROJECTID }}\n with:\n args: |\n setup:emulators:firestore --debug\n firebase emulators:exec --debug --only functions,firestore \\"npm run test --exit -- --forceExit --detectOpenHandles\\"\n\n - name: Print debug logs\n if: failure()\n run: |\n java --version\n ls -la\n find . -type f -name "fire*-debug.log" | xargs cat\n
Run Code Online (Sandbox Code Playgroud)\n\n这就是操作的输出name: Test
/usr/bin/docker run --name d38e5ad93a422d456db01475acdae41155_521526 --label 3888d3 --workdir /github/workspace --rm -e JAVA_HOME -e FIREBASE_TOKEN -e GCLOUD_PROJECT -e PROJECT_ID -e INPUT_ARGS -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true --network github_network_2107949b3a2c43d499d641b1c2f0fd12 -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/pwa/pwa":"/github/workspace" 3888d3:8e5ad93a422d456db01475acdae41155 setup:emulators:firestore --debug\nfirebase emulators:exec --debug --only functions,firestore \\"npm run test --exit -- --forceExit --detectOpenHandles\\"\nsetting firebase project to ***\nNow using project ***\ni firestore: downloading cloud-firestore-emulator-v1.11.4.jar... {"metadata":{"emulator":{"name":"firestore"},"message":"downloading cloud-firestore-emulator-v1.11.4.jar..."}}\n\n[2020-06-06T12:59:30.184Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]\n[2020-06-06T12:59:30.186Z] > authorizing via FIREBASE_TOKEN environment variable\ni emulators: Starting emulators: functions, firestore {"metadata":{"emulator":{"name":"hub"},"message":"Starting emulators: functions, firestore"}}\n[2020-06-06T12:59:30.217Z] [hub] writing locator at /tmp/hub-***.json\n\xe2\x9c\x94 functions: Using node@10 from host. {"metadata":{"emulator":{"name":"functions"},"message":"Using node@10 from host."}}\n[2020-06-06T12:59:30.249Z] Ignoring unsupported arg: projectId {"metadata":{"emulator":{"name":"firestore"},"message":"Ignoring unsupported arg: projectId"}}\n[2020-06-06T12:59:30.249Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"firestore"},"message":"Ignoring unsupported arg: auto_download"}}\n[2020-06-06T12:59:30.249Z] Starting Firestore Emulator with command {"binary":"java","args":["-Duser.language=en","-jar","/github/home/.cache/firebase/emulators/cloud-firestore-emulator-v1.11.4.jar","--host","localhost","--port",8080,"--rules","/github/workspace/firestore.rules","--functions_emulator","localhost:5001"],"optionalArgs":["port","webchannel_port","host","rules","functions_emulator","seed_from_export"],"joinArgs":false} {"metadata":{"emulator":{"name":"firestore"},"message":"Starting Firestore Emulator with command {\\"binary\\":\\"java\\",\\"args\\":[\\"-Duser.language=en\\",\\"-jar\\",\\"/github/home/.cache/firebase/emulators/cloud-firestore-emulator-v1.11.4.jar\\",\\"--host\\",\\"localhost\\",\\"--port\\",8080,\\"--rules\\",\\"/github/workspace/firestore.rules\\",\\"--functions_emulator\\",\\"localhost:5001\\"],\\"optionalArgs\\":[\\"port\\",\\"webchannel_port\\",\\"host\\",\\"rules\\",\\"functions_emulator\\",\\"seed_from_export\\"],\\"joinArgs\\":false}"}}\ni firestore: Firestore Emulator logging to firestore-debug.log {"metadata":{"emulator":{"name":"firestore"},"message":"Firestore Emulator logging to \\u001b[1mfirestore-debug.log\\u001b[22m"}}\n\nError: firestore: Firestore Emulator has exited because java is not installed, you can install it from https://openjdk.java.net/install/\n
Run Code Online (Sandbox Code Playgroud)\n\n这就是操作的输出name: Print debug logs
[debug] [2020-06-06T12:59:27.289Z] ----------------------------------------------------------------------\n[debug] [2020-06-06T12:59:27.291Z] Command: /usr/local/bin/node /usr/local/bin/firebase setup:emulators:firestore --debug\n[debug] [2020-06-06T12:59:27.292Z] CLI Version: 8.4.2\n[debug] [2020-06-06T12:59:27.292Z] Platform: linux\n[debug] [2020-06-06T12:59:27.292Z] Node Version: v10.21.0\n[debug] [2020-06-06T12:59:27.292Z] Time: Sat Jun 06 2020 12:59:27 GMT+0000 (Coordinated Universal Time)\n[debug] [2020-06-06T12:59:27.293Z] ----------------------------------------------------------------------\n[debug] [2020-06-06T12:59:27.293Z]\n[info] i firestore: downloading cloud-firestore-emulator-v1.11.4.jar... {"metadata":{"emulator":{"name":"firestore"},"message":"downloading cloud-firestore-emulator-v1.11.4.jar..."}}\n[debug] [2020-06-06T12:59:30.168Z] ----------------------------------------------------------------------\n[debug] [2020-06-06T12:59:30.170Z] Command: /usr/local/bin/node /usr/local/bin/firebase emulators:exec --debug --only functions,firestore npm run test --exit -- --forceExit --detectOpenHandles\n[debug] [2020-06-06T12:59:30.171Z] CLI Version: 8.4.2\n[debug] [2020-06-06T12:59:30.171Z] Platform: linux\n[debug] [2020-06-06T12:59:30.171Z] Node Version: v10.21.0\n[debug] [2020-06-06T12:59:30.171Z] Time: Sat Jun 06 2020 12:59:30 GMT+0000 (Coordinated Universal Time)\n[debug] [2020-06-06T12:59:30.171Z] ----------------------------------------------------------------------\n[debug] [2020-06-06T12:59:30.171Z]\n[debug] [2020-06-06T12:59:30.184Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]\n[debug] [2020-06-06T12:59:30.186Z] > authorizing via FIREBASE_TOKEN environment variable\n[info] i emulators: Starting emulators: functions, firestore {"metadata":{"emulator":{"name":"hub"},"message":"Starting emulators: functions, firestore"}}\n[debug] [2020-06-06T12:59:30.217Z] [hub] writing locator at /tmp/hub-***.json\n[info] \xe2\x9c\x94 functions: Using node@10 from host. {"metadata":{"emulator":{"name":"functions"},"message":"Using node@10 from host."}}\n[debug] [2020-06-06T12:59:30.249Z] Ignoring unsupported arg: projectId {"metadata":{"emulator":{"name":"firestore"},"message":"Ignoring unsupported arg: projectId"}}\n[debug] [2020-06-06T12:59:30.249Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"firestore"},"message":"Ignoring unsupported arg: auto_download"}}\n[debug] [2020-06-06T12:59:30.249Z] Starting Firestore Emulator with command {"binary":"java","args":["-Duser.language=en","-jar","/github/home/.cache/firebase/emulators/cloud-firestore-emulator-v1.11.4.jar","--host","localhost","--port",8080,"--rules","/github/workspace/firestore.rules","--functions_emulator","localhost:5001"],"optionalArgs":["port","webchannel_port","host","rules","functions_emulator","seed_from_export"],"joinArgs":false} {"metadata":{"emulator":{"name":"firestore"},"message":"Starting Firestore Emulator with command {\\"binary\\":\\"java\\",\\"args\\":[\\"-Duser.language=en\\",\\"-jar\\",\\"/github/home/.cache/firebase/emulators/cloud-firestore-emulator-v1.11.4.jar\\",\\"--host\\",\\"localhost\\",\\"--port\\",8080,\\"--rules\\",\\"/github/workspace/firestore.rules\\",\\"--functions_emulator\\",\\"localhost:5001\\"],\\"optionalArgs\\":[\\"port\\",\\"webchannel_port\\",\\"host\\",\\"rules\\",\\"functions_emulator\\",\\"seed_from_export\\"],\\"joinArgs\\":false}"}}\n[info] i firestore: Firestore Emulator logging to firestore-debug.log {"metadata":{"emulator":{"name":"firestore"},"message":"Firestore Emulator logging to \\u001b[1mfirestore-debug.log\\u001b[22m"}}\n[error]\n[error] Error: firestore: Firestore Emulator has exited because java is not installed, you can install it from https://openjdk.java.net/install/\n
Run Code Online (Sandbox Code Playgroud)\n\n如何在 Github Actions 上运行测试?
\n在撰写本文时,非官方的firebase-action最近添加了 Java 支持。不幸的是,这是 Java 7,模拟器需要 Java 8。(我在存储库中打开了一个问题来修复此问题)。
另外,对于任何感兴趣的人,我发现以下方法效果很好:
name: Test Firebase rules on PR
'on': pull_request
jobs:
test_rules:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '12'
- run: npm install -g firebase-tools
- run: npm ci
- run: firebase emulators:exec --only firestore \"npm run test --exit\"
Run Code Online (Sandbox Code Playgroud)
关于上述工作流程文件有两个重要注意事项:
ubuntu-latest
是必需的,因为它包含节点和 java。actions/setup-node@v1
需要设置节点以允许安装全局 npm 包。另外,如果您想在上述步骤中添加部署步骤,则只需将其添加到步骤上方即可setup-node
进行身份验证:
- uses: google-github-actions/setup-gcloud@master
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
export_default_credentials: true
Run Code Online (Sandbox Code Playgroud)
(这是因为将export_default_credentials
导出GOOGLE_APPLICATION_CREDENTIALS
firebase-tools 将用于身份验证的环境变量)。
尝试这个 -
name: next
on:
push:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Setting-up Node.js
uses: actions/setup-node@v2-beta
with:
node-version: '10'
- name: Installing npm dependencies
run: npm ci --prefer-offline --no-audit --progress=false
- name: Checking-out
uses: actions/checkout@v2
- name: Setting-up JAVA
uses: actions/setup-java@v1.3.0
with:
java-version: "12.x"
- name: Setup and Test Emulator
uses: w9jds/firebase-action@v1.3.1
env:
JAVA_HOME: ${{ env.JAVA_HOME }}
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
GCLOUD_PROJECT: ${{ secrets.nextGCLOUD_PROJECT }}
PROJECT_ID: ${{ secrets.nextFIREBASE_PROJECTID }}
with:
args: |
setup:emulators:firestore
emulators:exec --only firestore \"npm run test --exit\"
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5499 次 |
最近记录: |