Skip to content

Commit

Permalink
abstracted more reusable workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
imolorhe committed Jul 23, 2024
1 parent 0caf1a4 commit c491835
Show file tree
Hide file tree
Showing 11 changed files with 275 additions and 244 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,27 @@ on:
required: false
default: true
type: boolean
workflow_dispatch:
inputs:
node_version:
description: 'Node.js version to use'
required: true
type: string
deploy_docs:
description: 'Whether to deploy docs'
required: false
default: true
type: boolean
deploy_redirect:
description: 'Whether to deploy redirect'
required: false
default: true
type: boolean
deploy_sandbox:
description: 'Whether to deploy sandbox'
required: false
default: true
type: boolean

jobs:
deploy:
Expand Down
File renamed without changes.
File renamed without changes.
27 changes: 27 additions & 0 deletions .github/workflows/_push-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Docker push workflow

on:
workflow_call:
inputs:
push:
description: 'Whether to push the Docker image'
required: true
type: boolean

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
load: true
push: ${{ inputs.push }}
tags: ${{ inputs.push && format('{0}/altairgraphqlapi:latest', secrets.DOCKERHUB_USERNAME) || '' }}
144 changes: 144 additions & 0 deletions .github/workflows/_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
name: Tests workflow

on:
workflow_call:
inputs:
node_version:
description: 'Node.js version to use'
required: true
type: string
workflow_dispatch:
inputs:
node_version:
description: 'Node.js version to use'
required: true
type: string

jobs:
test:
strategy:
matrix:
os: [macos-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Use Node.js ${{ inputs.node_version }} on ${{ matrix.os }}
uses: actions/setup-node@v1
with:
node-version: ${{ inputs.node_version }}
- uses: nrwl/nx-set-shas@v2
with:
main-branch-name: master
# - name: restore lerna
# uses: actions/cache@v2
# with:
# path: |
# node_modules
# */*/node_modules
# key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- run: yarn --frozen-lockfile --network-timeout 1000000
- uses: browser-actions/setup-chrome@latest
- name: Build apps (with retries)
uses: nick-invision/retry@v2
with:
timeout_minutes: 15
max_attempts: 3
command: yarn build:ci
- name: Run headless test
uses: GabrielBB/xvfb-action@v1
with:
run: yarn test:ci:retries
# https://github.com/tanshuai/electron-playwright-e2e-test-quick-start/blob/1e2c653bc2d0af85d98de1c58e56a888f17fe671/.github/workflows/ci.yml#L39-L44
- name: Upload Test Results 🗃
if: always()
uses: actions/upload-artifact@v2
with:
name: screenshots
path: packages/altair-electron/e2e/*.png
e2e-test:
strategy:
matrix:
os: [macos-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ inputs.node_version }} on ${{ matrix.os }}
uses: actions/setup-node@v1
with:
node-version: ${{ inputs.node_version }}
- name: restore lerna
uses: actions/cache@v2
with:
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- run: yarn --frozen-lockfile --network-timeout 1000000
- uses: browser-actions/setup-chrome@latest
- name: Build apps (with retries)
uses: nick-invision/retry@v2
with:
timeout_minutes: 15
max_attempts: 3
command: yarn build:ci
- run: npx playwright install
- name: Run headless e2e test
uses: GabrielBB/xvfb-action@v1
with:
run: yarn playwright test --retries 2
env:
NODE_OPTIONS: --max_old_space_size=4096

api-e2e-test:
# Containers must run in Linux based operating systems
runs-on: ubuntu-latest

# Service containers to run with `container-job`
services:
# Label used to access the service container
postgres:
image: postgres:13
env:
POSTGRES_USER: prisma
POSTGRES_PASSWORD: prisma
POSTGRES_DB: tests
ports:
- 5434:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
# Downloads a copy of the code in your repository before running CI tests
- name: Check out repository code
uses: actions/checkout@v3
- uses: actions/setup-node@v1
with:
node-version: ${{ inputs.node_version }}
- name: restore lerna
uses: actions/cache@v2
with:
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- run: yarn --frozen-lockfile --network-timeout 1000000
- name: Build apps (with retries)
uses: nick-invision/retry@v2
with:
timeout_minutes: 15
max_attempts: 3
command: yarn build:ci
# - name: Update env file
# run: |
# echo DATABASE_URL="postgresql://prisma:prisma@postgres:5434/tests?schema=public" >> packages/altair-api/.env.e2e
# cat packages/altair-api/.env.e2e
- name: Migration
run: yarn --cwd packages/altair-api migrate:e2e
- name: Run E2E
run: yarn --cwd packages/altair-api test:e2e
58 changes: 29 additions & 29 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
name: 'CodeQL'

on:
push:
branches: [ staging, master ]
branches: [staging, master]
pull_request:
# The branches below must be a subset of the branches above
branches: [ staging ]
branches: [staging]
schedule:
- cron: '36 7 * * 1'

Expand All @@ -28,40 +28,40 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'javascript', 'typescript' ]
language: ['javascript', 'typescript', 'yaml']
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release
#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
64 changes: 0 additions & 64 deletions .github/workflows/pr-master-api-e2e.yml

This file was deleted.

46 changes: 0 additions & 46 deletions .github/workflows/pr-master-e2e.yml

This file was deleted.

Loading

0 comments on commit c491835

Please sign in to comment.