Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: ci: standardize #217

Merged
merged 7 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 0 additions & 91 deletions .github/workflows/build-docker-image.yaml

This file was deleted.

22 changes: 22 additions & 0 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: "check and build"
on:
pull_request:
push:
branches:
- main

jobs:
tests:
uses: ./.github/workflows/wf_check.yaml
with:
NAME: hasura-storage
GIT_REF: ${{ github.event.pull_request.head.sha }}

build_artifacts:
uses: ./.github/workflows/wf_build_artifacts.yaml
with:
NAME: hasura-storage
VERSION: 0.0.0-dev # hardcoded to avoid rebuilding
DOCKER: true
GIT_REF: ${{ github.event.pull_request.head.sha }}
49 changes: 0 additions & 49 deletions .github/workflows/copy-docker-image-to-aws.yaml

This file was deleted.

10 changes: 0 additions & 10 deletions .github/workflows/push.yaml

This file was deleted.

33 changes: 20 additions & 13 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,27 @@ on:

jobs:
tests:
uses: nhost/hasura-storage/.github/workflows/test.yaml@main
secrets:
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
uses: ./.github/workflows/wf_check.yaml
with:
NAME: hasura-storage

build_artifacts:
uses: ./.github/workflows/wf_build_artifacts.yaml
with:
NAME: hasura-storage
VERSION: ${{ github.ref_name }}
DOCKER: true

build:
needs: tests
uses: nhost/hasura-storage/.github/workflows/build-docker-image.yaml@main
push_docker_image:
uses: ./.github/workflows/wf_docker_push_image.yaml
needs:
- tests # we depend of tests here to paralleliza tests and build
- build_artifacts
with:
NAME: hasura-storage
VERSION: ${{ github.ref_name }}
AWS_REGION: eu-central-1
secrets:
AWS_ACCOUNT_ID: ${{ secrets.AWS_PRODUCTION_CORE_ACCOUNT_ID }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}

copy-to-aws-production:
needs: build
uses: nhost/hasura-storage/.github/workflows/copy-docker-image-to-aws.yaml@main
secrets:
AWS_ACCOUNT_ID: ${{ secrets.AWS_PRODUCTION_ACCOUNT_ID }}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: "main: Release drafter"
name: "Release drafter"
on:
push:
branches:
Expand Down
42 changes: 0 additions & 42 deletions .github/workflows/test.yaml

This file was deleted.

106 changes: 106 additions & 0 deletions .github/workflows/wf_build_artifacts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
---
on:
workflow_call:
inputs:
NAME:
type: string
required: true
GIT_REF:
type: string
required: false
VERSION:
type: string
required: true
PATH:
type: string
default: "."
required: false
DOCKER:
type: boolean
required: true

jobs:
artifacts:
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
permissions:
id-token: write
contents: write

strategy:
matrix:
os: [ubuntu-22.04, ubuntu-arm64-22.04-2cores]
fail-fast: true

runs-on: ${{ matrix.os }}
timeout-minutes: 180

steps:
- name: "Check out repository"
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ inputs.GIT_REF }}

- uses: cachix/install-nix-action@v27
with:
install_url: "https://releases.nixos.org/nix/nix-2.22.3/install"
install_options: "--no-daemon"
extra_nix_config: |
experimental-features = nix-command flakes
sandbox = false
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
substituters = https://cache.nixos.org/?priority=40
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=

- uses: DeterminateSystems/magic-nix-cache-action@v7
with:
diagnostic-endpoint: ""
use-flakehub: false

- name: "Verify if we need to build"
id: verify-build
run: |
export drvPath=$(make check-dry-run)
echo "drvPath - $drvPath"
nix store verify --no-trust --store http://127.0.0.1:37515 $drvPath \
&& export BUILD_NEEDED=no \
|| export BUILD_NEEDED=yes

echo BUILD_NEEDED=$BUILD_NEEDED >> $GITHUB_OUTPUT
echo DERIVATION_PATH=$drvPath >> $GITHUB_OUTPUT

- name: Compute common env vars
id: vars
run: |
echo "VERSION=$(make get-version VER=${{ inputs.VERSION }})" >> $GITHUB_OUTPUT

- name: "Build artifact"
run: |
make build
zip -r result.zip result

- name: "Push artifact to artifact repository"
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.NAME }}-artifact-${{ matrix.os }}-${{ steps.vars.outputs.VERSION }}
path: result/bin/hasura-storage
retention-days: 7

- name: "Build docker image"
run: |
make build-docker-image
if: ${{ ( inputs.DOCKER ) }}

- name: "Push docker image to artifact repository"
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.NAME }}-docker-image-${{ matrix.os }}-${{ steps.vars.outputs.VERSION }}
path: result
retention-days: 7
if: ${{ ( inputs.DOCKER ) }}

# - name: "Cache build environment"
# run: |
# # DEPENDENCIES=($(nix-store --query --requisites --include-outputs ${{ steps.verify-build.outputs.DERIVATION_PATH }}))
# nix copy --to http://127.0.0.1:37515 "${DEPENDENCIES[@]}" || exit 0
# if: ${{ steps.verify-build.outputs.BUILD_NEEDED == 'yes' }}
Comment on lines +102 to +106
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this step commented ?

Loading
Loading