CI (Linting, Testing, Building) #54
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: CI (Linting, Testing, Building) | |
on: | |
push: | |
branches: ["*"] | |
pull_request: | |
branches: ["main"] | |
workflow_dispatch: | |
jobs: | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [20.x] | |
go-version: [1.21.x] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ matrix.go-version }} | |
- name: Install Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: "yarn" | |
cache-dependency-path: "client/yarn.lock" | |
- name: Install Node.js dependencies | |
run: | | |
cd client | |
yarn install | |
- name: Lint React Native code | |
run: | | |
cd client | |
yarn lint | |
- name: Lint Go code | |
run: | | |
cd server | |
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest | |
golangci-lint run ./... | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [20.x] | |
go-version: [1.21.x] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ matrix.go-version }} | |
- name: Install Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: "yarn" | |
cache-dependency-path: "client/yarn.lock" | |
- name: Install Node.js dependencies | |
run: | | |
cd client | |
yarn install | |
- name: Kill existing PostgreSQL process | |
run: | | |
sudo service postgresql stop || true | |
continue-on-error: true | |
- name: Start Postgresql | |
run: | | |
sudo service postgresql start | |
sleep 5 | |
cd scripts | |
./verify_os.sh | |
- name: Run React Native tests | |
run: | | |
cd client | |
yarn test | |
- name: Run Go tests | |
run: | | |
cd server/tests | |
go test ./... | |
- name: Clean up PostgreSQL container | |
run: | | |
docker stop ${CONTAINER_NAME} || true | |
docker rm ${CONTAINER_NAME} || true | |
continue-on-error: true | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [20.x] | |
go-version: [1.21.x] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ matrix.go-version }} | |
- name: Install Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: "yarn" | |
cache-dependency-path: "client/yarn.lock" | |
- name: Install Node.js dependencies | |
run: | | |
cd client | |
yarn install | |
- name: Build Go app | |
run: | | |
cd server | |
go build -v ./src/... |