Skip to content

Commit

Permalink
Github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
iamvigneshwars committed Apr 26, 2024
1 parent 300be5e commit 97e6cf1
Show file tree
Hide file tree
Showing 5 changed files with 317 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
groups:
github-artifacts:
patterns:
- actions/*-artifact
minor:
update-types:
- minor
- patch

- package-ecosystem: devcontainers
directory: /
schedule:
interval: weekly
groups:
minor:
update-types:
- minor
- patch

- package-ecosystem: docker
directory: /
schedule:
interval: weekly
groups:
minor:
update-types:
- minor
- patch

- package-ecosystem: cargo
directory: /
schedule:
interval: weekly
groups:
patch:
update-types:
- patch
104 changes: 104 additions & 0 deletions .github/workflows/code.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Backend Code

on:
push:
pull_request:

jobs:
lint:
# Deduplicate jobs from pull requests and branch pushes within the same repo.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
services:
ispyb:
image: ghcr.io/diamondlightsource/ispyb-database:v3.0.0
ports:
- 3306:3306
env:
MARIADB_ROOT_PASSWORD: rootpassword
options: >
--health-cmd "/usr/local/bin/healthcheck.sh --defaults-file=/ispyb/.my.cnf --connect"
env:
DATABASE_URL: mysql://root:rootpassword@localhost/ispyb_build
steps:
- name: Checkout source
uses: actions/[email protected]

- name: Install dependencies
uses: awalsh128/[email protected]
with:
packages: libopencv-dev clang libclang-dev

- name: Install stable toolchain
uses: actions-rs/[email protected]
with:
toolchain: stable
default: true

- name: Cache Rust Build
uses: Swatinem/[email protected]

- name: Create models lib file
run: |
mkdir models/src
printf "\n" > models/src/lib.rs
- name: Check Formatting
uses: actions-rs/[email protected]
with:
command: fmt
args: >
--all
--check
- name: Lint with Clippy
uses: actions-rs/[email protected]
with:
command: clippy
args: >
--no-deps
--all-targets
--all-features
--
--deny warnings
test:
# Deduplicate jobs from pull requests and branch pushes within the same repo.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
services:
ispyb:
image: ghcr.io/diamondlightsource/ispyb-database:v3.0.0
ports:
- 3306:3306
env:
MARIADB_ROOT_PASSWORD: rootpassword
options: >
--health-cmd "/usr/local/bin/healthcheck.sh --defaults-file=/ispyb/.my.cnf --connect"
env:
DATABASE_URL: mysql://root:rootpassword@localhost/ispyb_build
steps:
- name: Checkout source
uses: actions/[email protected]

- name: Install dependencies
uses: awalsh128/[email protected]
with:
packages: libopencv-dev clang libclang-dev

- name: Install stable toolchain
uses: actions-rs/[email protected]
with:
toolchain: stable
default: true

- name: Cache Rust Build
uses: Swatinem/[email protected]

- name: Test
uses: actions-rs/[email protected]
with:
command: test
args: >
--all-targets
--all-features
64 changes: 64 additions & 0 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Container

on:
push:
pull_request:

jobs:
build:
# Deduplicate jobs from pull requests and branch pushes within the same repo.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
services:
ispyb:
image: ghcr.io/diamondlightsource/ispyb-database:v3.0.0
ports:
- 3306:3306
env:
MARIADB_ROOT_PASSWORD: rootpassword
options: >
--health-cmd "/usr/local/bin/healthcheck.sh --defaults-file=/ispyb/.my.cnf --connect"
permissions:
contents: read
packages: write
steps:
- name: Checkout Code
uses: actions/[email protected]

- name: Generate Image Name
run: echo IMAGE_REPOSITORY=ghcr.io/$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]' | tr '[_]' '[\-]') >> $GITHUB_ENV

- name: Log in to GitHub Docker Registry
if: github.event_name != 'pull_request'
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker Metadata
id: meta
uses: docker/[email protected]
with:
images: ${{ env.IMAGE_REPOSITORY }}
tags: |
type=ref,event=tag
type=raw,value=latest
- name: Set up Docker Buildx
uses: docker/[email protected]
with:
driver-opts: network=host

- name: Build Image
uses: docker/[email protected]
with:
build-args: DATABASE_URL=mysql://root:rootpassword@localhost:3306/ispyb_build
target: deploy
push: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
load: ${{ !(github.event_name == 'push' && startsWith(github.ref, 'refs/tags')) }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

23 changes: 23 additions & 0 deletions .github/workflows/devcontainer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Dev Container CI

on:
push:
pull_request:

jobs:
build:
# pull requests are a duplicate of a branch push if within the same repo.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]

- name: Set up Docker Buildx
uses: docker/[email protected]

- name: Create .env file
run: touch .devcontainer/opa.env

- name: Build dev container
uses: devcontainers/[email protected]
83 changes: 83 additions & 0 deletions .github/workflows/schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Schema

on:
push:
pull_request:

jobs:
generate:
# Deduplicate jobs from pull requests and branch pushes within the same repo.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
services:
ispyb:
image: ghcr.io/diamondlightsource/ispyb-database:v3.0.0
ports:
- 3306:3306
env:
MARIADB_ROOT_PASSWORD: rootpassword
options: >
--health-cmd "/usr/local/bin/healthcheck.sh --defaults-file=/ispyb/.my.cnf --connect"
env:
DATABASE_URL: mysql://root:rootpassword@localhost:3306/ispyb_build
steps:
- name: Checkout source
uses: actions/[email protected]

- name: Install stable toolchain
uses: actions-rs/[email protected]
with:
toolchain: stable
default: true

- name: Cache Rust Build
uses: Swatinem/[email protected]

- name: Generate Schema
uses: actions-rs/[email protected]
with:
command: run
args: >
schema
--path fluorescence_scan.graphql
- name: Upload Schema Artifact
uses: actions/[email protected]
with:
name: fluorescence_scan.graphql
path: fluorescence_scan.graphql

publish:
# Deduplicate jobs from pull requests and branch pushes within the same repo.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
needs:
- generate
runs-on: ubuntu-latest
steps:
- name: Install Rover CLI
run: |
curl -sSL https://rover.apollo.dev/nix/v0.23.0-rc.3 | sh
echo "$HOME/.rover/bin" >> $GITHUB_PATH
- name: Download Schema Artifact
uses: actions/[email protected]
with:
name: fluorescence_scan.graphql

- name: Check Subgraph Schema
run: >
rover subgraph check data-gateway-n63jcf@current
--schema fluorescence_scan.graphql
--name fluorescence-scan
env:
APOLLO_KEY: ${{ secrets.APOLLO_STUDIO }}

- name: Publish Subgraph Schema to Apollo Studio
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
run: >
rover subgraph publish data-gateway-n63jcf@current
--routing-url http://fluorescence-scan:80
--schema fluorescence_scan.graphql
--name fluorescence-scan
env:
APOLLO_KEY: ${{ secrets.APOLLO_STUDIO }}

0 comments on commit 97e6cf1

Please sign in to comment.