This repository has been archived by the owner on Aug 20, 2024. It is now read-only.
Merge pull request #2194 from sue445/dependabot/go_modules/function/g… #1437
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: function-build | |
on: | |
push: | |
branches: | |
- master | |
paths-ignore: | |
# Ignore files that are not used in production | |
- "**.md" | |
- "LICENSE" | |
- ".github/workflows/dependabot-auto-merge.yml" | |
- "function/_img/**" | |
- "function/_script/**" | |
- ".github/dependabot.yml" | |
- ".github/dependabot-auto-merge.yml" | |
# Ignore files used only by the frontend | |
- "frontend/**" | |
- ".github/workflows/frontend-*.yml" | |
pull_request: | |
types: | |
- opened | |
- synchronize | |
- reopened | |
paths-ignore: | |
# Ignore files that are not used in production | |
- "**.md" | |
- "LICENSE" | |
- ".github/workflows/dependabot-auto-merge.yml" | |
- ".github/dependabot-auto-merge.yml" | |
- "function/_img/**" | |
# Ignore files used only by the frontend | |
- "frontend/**" | |
- ".github/workflows/frontend-*.yml" | |
env: | |
TEST_ARGS: -coverprofile coverage.out -covermode atomic | |
defaults: | |
run: | |
working-directory: function | |
jobs: | |
test: | |
name: test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: "function/go.mod" | |
cache-dependency-path: "function/go.sum" | |
id: go | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: ".nvmrc" | |
- name: Install firebase emulator | |
run: | | |
set -xe | |
npm install -g firebase-tools | |
firebase setup:emulators:firestore | |
firebase setup:emulators:pubsub | |
- name: Run test | |
run: | | |
set -xe | |
firebase --project $GCP_PROJECT emulators:exec --only firestore,pubsub "make test" | |
firebase --project $GCP_PROJECT emulators:exec --only firestore,pubsub "make testrace" | |
env: | |
GCP_PROJECT: test | |
PUBSUB_PROJECT_ID: test | |
PUBSUB_EMULATOR_HOST: localhost:8085 | |
# FIXME: gcov2lcov-action doesn't support mono repo... | |
# - name: Convert coverage to lcov | |
# uses: jandelgado/gcov2lcov-action@v1.0.0 | |
# with: | |
# infile: coverage.out | |
# outfile: coverage.lcov | |
- name: Install gcov2lcov | |
run: | | |
set -xe | |
wget https://github.com/jandelgado/gcov2lcov/releases/download/${VERSION}/gcov2lcov-linux-amd64.tar.gz -q -O - | tar xvzf - --strip 1 | |
chmod 755 gcov2lcov-linux-amd64 | |
env: | |
VERSION: v1.0.4 | |
working-directory: /tmp | |
- name: Run gcov2lcov | |
run: | | |
set -xe | |
exec /tmp/gcov2lcov-linux-amd64 -infile "coverage.out" -outfile "coverage.lcov" | |
- name: Coveralls | |
uses: coverallsapp/github-action@master | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
path-to-lcov: function/coverage.lcov | |
continue-on-error: true | |
- name: Slack Notification (not success) | |
uses: act10ns/slack@v2 | |
if: "! success()" | |
continue-on-error: true | |
with: | |
status: ${{ job.status }} | |
webhook-url: ${{ secrets.SLACK_WEBHOOK }} | |
lint: | |
name: lint | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: "function/go.mod" | |
cache-dependency-path: "function/go.sum" | |
id: go | |
- name: Run lint | |
run: | | |
set -xe | |
go install golang.org/x/lint/golint@latest | |
make fmtci | |
make vet | |
make lint | |
- name: Slack Notification (not success) | |
uses: act10ns/slack@v2 | |
if: "! success()" | |
continue-on-error: true | |
with: | |
status: ${{ job.status }} | |
webhook-url: ${{ secrets.SLACK_WEBHOOK }} | |
go2ts: | |
name: go2ts | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: "function/go.mod" | |
cache-dependency-path: "function/go.sum" | |
id: go | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: ".nvmrc" | |
cache: "npm" | |
cache-dependency-path: "frontend/package-lock.json" | |
- run: npm install | |
working-directory: frontend | |
- name: "[NOTE] Run `make go2ts` if this is failed" | |
run: | | |
set -xe | |
make go2ts_ci | |
git checkout HEAD -- go.mod go.sum | |
git --no-pager diff | |
git status | grep "nothing to commit, working tree clean" | |
- name: Slack Notification (not success) | |
uses: act10ns/slack@v2 | |
if: "! success()" | |
continue-on-error: true | |
with: | |
status: ${{ job.status }} | |
webhook-url: ${{ secrets.SLACK_WEBHOOK }} | |
notify: | |
needs: | |
- test | |
- lint | |
- go2ts | |
runs-on: ubuntu-latest | |
steps: | |
- name: Slack Notification (success) | |
uses: act10ns/slack@v2 | |
if: always() | |
continue-on-error: true | |
with: | |
status: ${{ job.status }} | |
webhook-url: ${{ secrets.SLACK_WEBHOOK }} |