在github操作上运行firebase模拟器
我正试图在Github Actinos上运行我的测试,但经过几次尝试后,我都没能做到 接收 错误:firestore:firestore Emulator已退出,因为未安装java,您可以从中安装它在github操作上运行firebase模拟器,firebase,unit-testing,continuous-integration,github-actions,firebase-tools,Firebase,Unit Testing,Continuous Integration,Github Actions,Firebase Tools,我正试图在Github Actinos上运行我的测试,但经过几次尝试后,我都没能做到 接收 错误:firestore:firestore Emulator已退出,因为未安装java,您可以从中安装它 这是actionname:Test的输出 /usr/bin/docker run --name d38e5ad93a422d456db01475acdae41155_521526 --label 3888d3 --workdir /github/workspace --rm -e JAVA_HOM
这是action
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
firebase emulators:exec --debug --only functions,firestore \"npm run test --exit -- --forceExit --detectOpenHandles\"
setting firebase project to ***
Now using project ***
i firestore: downloading cloud-firestore-emulator-v1.11.4.jar... {"metadata":{"emulator":{"name":"firestore"},"message":"downloading cloud-firestore-emulator-v1.11.4.jar..."}}
[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"]
[2020-06-06T12:59:30.186Z] > authorizing via FIREBASE_TOKEN environment variable
i emulators: Starting emulators: functions, firestore {"metadata":{"emulator":{"name":"hub"},"message":"Starting emulators: functions, firestore"}}
[2020-06-06T12:59:30.217Z] [hub] writing locator at /tmp/hub-***.json
✔ functions: Using node@10 from host. {"metadata":{"emulator":{"name":"functions"},"message":"Using node@10 from host."}}
[2020-06-06T12:59:30.249Z] Ignoring unsupported arg: projectId {"metadata":{"emulator":{"name":"firestore"},"message":"Ignoring unsupported arg: projectId"}}
[2020-06-06T12:59:30.249Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"firestore"},"message":"Ignoring unsupported arg: auto_download"}}
[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}"}}
i firestore: Firestore Emulator logging to firestore-debug.log {"metadata":{"emulator":{"name":"firestore"},"message":"Firestore Emulator logging to \u001b[1mfirestore-debug.log\u001b[22m"}}
Error: firestore: Firestore Emulator has exited because java is not installed, you can install it from https://openjdk.java.net/install/
这是操作name:Print debug logs
[debug] [2020-06-06T12:59:27.289Z] ----------------------------------------------------------------------
[debug] [2020-06-06T12:59:27.291Z] Command: /usr/local/bin/node /usr/local/bin/firebase setup:emulators:firestore --debug
[debug] [2020-06-06T12:59:27.292Z] CLI Version: 8.4.2
[debug] [2020-06-06T12:59:27.292Z] Platform: linux
[debug] [2020-06-06T12:59:27.292Z] Node Version: v10.21.0
[debug] [2020-06-06T12:59:27.292Z] Time: Sat Jun 06 2020 12:59:27 GMT+0000 (Coordinated Universal Time)
[debug] [2020-06-06T12:59:27.293Z] ----------------------------------------------------------------------
[debug] [2020-06-06T12:59:27.293Z]
[info] i firestore: downloading cloud-firestore-emulator-v1.11.4.jar... {"metadata":{"emulator":{"name":"firestore"},"message":"downloading cloud-firestore-emulator-v1.11.4.jar..."}}
[debug] [2020-06-06T12:59:30.168Z] ----------------------------------------------------------------------
[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
[debug] [2020-06-06T12:59:30.171Z] CLI Version: 8.4.2
[debug] [2020-06-06T12:59:30.171Z] Platform: linux
[debug] [2020-06-06T12:59:30.171Z] Node Version: v10.21.0
[debug] [2020-06-06T12:59:30.171Z] Time: Sat Jun 06 2020 12:59:30 GMT+0000 (Coordinated Universal Time)
[debug] [2020-06-06T12:59:30.171Z] ----------------------------------------------------------------------
[debug] [2020-06-06T12:59:30.171Z]
[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"]
[debug] [2020-06-06T12:59:30.186Z] > authorizing via FIREBASE_TOKEN environment variable
[info] i emulators: Starting emulators: functions, firestore {"metadata":{"emulator":{"name":"hub"},"message":"Starting emulators: functions, firestore"}}
[debug] [2020-06-06T12:59:30.217Z] [hub] writing locator at /tmp/hub-***.json
[info] ✔ functions: Using node@10 from host. {"metadata":{"emulator":{"name":"functions"},"message":"Using node@10 from host."}}
[debug] [2020-06-06T12:59:30.249Z] Ignoring unsupported arg: projectId {"metadata":{"emulator":{"name":"firestore"},"message":"Ignoring unsupported arg: projectId"}}
[debug] [2020-06-06T12:59:30.249Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"firestore"},"message":"Ignoring unsupported arg: auto_download"}}
[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}"}}
[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"}}
[error]
[error] Error: firestore: Firestore Emulator has exited because java is not installed, you can install it from https://openjdk.java.net/install/
如何在Github操作上运行测试?试试这个-
名称:下一步
关于:
推送:
分支机构:[硕士]
工作:
建造:
运行于:ubuntu最新版本
步骤:
-名称:设置Node.js
用途:操作/设置-node@v2-贝塔
与:
节点版本:“10”
-名称:安装npm依赖项
运行:npm ci--首选脱机--无审核--进度=false
-姓名:退房
用途:行动/checkout@v2
-名称:设置JAVA
用途:操作/设置-java@v1.3.0
与:
java版本:“12.x”
-名称:安装和测试仿真器
用途:w9jds/firebase-action@v1.3.1
环境:
JAVA_HOME:${{env.JAVA_HOME}
FIREBASE_令牌:${{secrets.FIREBASE_令牌}
GCLOUD_项目:${{secrets.nextGCLOUD_项目}
项目ID:${{secrets.nextFIREBASE\u PROJECTID}
与:
args:|
设置:模拟器:firestore
模拟器:exec--仅firestore \“npm运行测试--退出\”
在撰写本文时,该非官方网站最近增加了Java支持。不幸的是,这是Java7,模拟器需要Java8。(我已在回购协议中开立了一个账户,以修复此问题)
或者,对于任何感兴趣的人,我发现以下方法很有效:
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\"
关于上述工作流文件,有两个重要注意事项:
ubuntu-latest
是必需的,因为它同时包含node和java
操作/设置-node@v1
是安装节点所必需的,以允许安装全局npm软件包
此外,如果要向上述步骤添加部署步骤,则只需在设置节点
步骤上方添加此步骤即可进行身份验证:
- 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
(这是因为export\u default\u credentials
将导出GOOGLE\u APPLICATION\u credentials
环境变量,firebase工具将使用该变量进行身份验证)。这对我有效
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '12'
- name: Install Dependacies
run: cd functions && npm install
- name: Test to Firebase
uses: w9jds/firebase-action@master
with:
args: emulators:exec --only firestore \"cd functions && npm run test --exit\"
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
不这不起作用,因为动作的工作方式<代码>w9jds/firebase操作
错误sh:2:emulators:exec:notfound
您可以在这里看到原因。。。试着在我的回答中拆分args我试着。。。我必须在emulator:exec之前添加firebase
,才能工作。。但还是一样的问题。。。
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '12'
- name: Install Dependacies
run: cd functions && npm install
- name: Test to Firebase
uses: w9jds/firebase-action@master
with:
args: emulators:exec --only firestore \"cd functions && npm run test --exit\"
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}