Skip to content

Commit

Permalink
Added new github workflows and actions
Browse files Browse the repository at this point in the history
  • Loading branch information
kpachhai committed May 6, 2024
1 parent b2720f8 commit 3bd7182
Show file tree
Hide file tree
Showing 16 changed files with 450 additions and 263 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @kpachhai
25 changes: 25 additions & 0 deletions .github/actions/install-go/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (C) 2023, AllianceBlock. All rights reserved.
# See the file LICENSE for licensing terms.

name: 'Install Go toolchain with defaults'
description: 'Install a go toolchain with defaults'

inputs:
cache:
description: 'to cache or not to cache, that is the question'
required: false
default: 'true'
cache-dependency-path:
description: 'forwards go actions/setup-go'
required: false

runs:
using: composite
steps:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21'
check-latest: true
cache: ${{ inputs.cache }}
cache-dependency-path: ${{ inputs.cache-dependency-path }}
25 changes: 25 additions & 0 deletions .github/actions/nuklai-wallet-release/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (C) 2023, AllianceBlock. All rights reserved.
# See the file LICENSE for licensing terms.

name: 'Release Nuklai Wallet'
description: 'Release the Nuklai Wallet'

runs:
using: composite
steps:
- name: Set up Go
uses: ./.github/actions/install-go
with:
cache-dependency-path: |
go.sum
- name: Build wallet
working-directory: ./cmd/nuklai-wallet
shell: bash
run: scripts/build.sh
env:
PUBLISH: 'false'
- name: Archive Builds
uses: actions/upload-artifact@v4
with:
name: nuklai-wallet
path: ./cmd/nuklai-wallet/nuklai-wallet.zip
55 changes: 55 additions & 0 deletions .github/actions/vm-release/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Copyright (C) 2023, AllianceBlock. All rights reserved.
# See the file LICENSE for licensing terms.

name: 'Release VM'
description: 'Release the VM'

inputs:
vm-name:
description: 'NuklaiVM'
required: true
github-token:
description: 'GitHub Token'
required: true

runs:
using: composite
steps:
- name: Set up Go
uses: ./.github/actions/install-go
with:
cache-dependency-path: |
go.sum
examples/${{ inputs.vm-name }}/go.sum
- name: Set up arm64 cross compiler
shell: bash
run: |
sudo apt-get -y update
sudo apt-get -y install gcc-aarch64-linux-gnu
- name: Checkout osxcross
uses: actions/checkout@v2
with:
repository: tpoechtrager/osxcross
path: osxcross
- name: Build osxcross
shell: bash
run: |
sudo apt-get -y install clang llvm-dev libxml2-dev uuid-dev libssl-dev bash patch make tar xz-utils bzip2 gzip sed cpio libbz2-dev
cd osxcross
wget https://github.com/joseluisq/macosx-sdks/releases/download/12.3/$MACOS_SDK_FNAME -O tarballs/$MACOS_SDK_FNAME
echo $MACOS_SDK_CHECKSUM tarballs/$MACOS_SDK_FNAME | sha256sum -c -
UNATTENDED=1 ./build.sh
echo $PWD/target/bin >> $GITHUB_PATH
env:
MACOS_SDK_FNAME: MacOSX12.3.sdk.tar.xz
MACOS_SDK_CHECKSUM: 3abd261ceb483c44295a6623fdffe5d44fc4ac2c872526576ec5ab5ad0f6e26c
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser
version: latest
args: release
workdir: ./examples/${{ inputs.vm-name }}/
env:
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret
GITHUB_TOKEN: ${{ inputs.github-token }}
78 changes: 78 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Copyright (C) 2023, AllianceBlock. All rights reserved.
# See the file LICENSE for licensing terms.

# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: 'CodeQL'

on:
push:
branches: ['main']
pull_request:
# The branches below must be a subset of the branches above
branches: ['main']
schedule:
- cron: '41 18 * * 3'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: ['go']
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

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

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
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.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
queries: security-extended,security-and-quality

# 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@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
38 changes: 0 additions & 38 deletions .github/workflows/load-tests.yml

This file was deleted.

146 changes: 146 additions & 0 deletions .github/workflows/nuklaivm-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# Copyright (C) 2023, AllianceBlock. All rights reserved.
# See the file LICENSE for licensing terms.

name: NuklaiVM CI
on:
push:
branches:
- main
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
go-mod-tidy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: ./.github/actions/install-go
- shell: bash
run: go mod tidy
- shell: bash
working-directory: ./
run: go mod tidy
- shell: bash
run: scripts/tests.clean.sh

nuklaivm-lint:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: ./.github/actions/install-go
with:
cache-dependency-path: |
go.sum
- name: Run static analysis tests
shell: bash
run: scripts/tests.lint.sh
- name: Run shellcheck
shell: bash
run: scripts/tests.shellcheck.sh
- name: Build vm, cli, faucet, feed
shell: bash
run: scripts/build.sh

nuklaivm-unit-tests:
runs-on: ubuntu-20.04-32
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: ./.github/actions/install-go
with:
cache-dependency-path: |
go.sum
- name: Run unit tests
shell: bash
run: scripts/tests.unit.sh
- name: Run integration tests
shell: bash
run: scripts/tests.integration.sh
# - name: Archive code coverage results (text)
# uses: actions/upload-artifact@v4
# with:
# name: code-coverage-out
# path: ./integration.coverage.out
# - name: Archive code coverage results (html)
# uses: actions/upload-artifact@v4
# with:
# name: code-coverage-html
# path: ./integration.coverage.html
- name: Run e2e tests
shell: bash
run: scripts/run.sh
env:
MODE: 'test'

nuklaivm-tests:
runs-on: ubuntu-latest
needs: [go-mod-tidy, nuklaivm-lint, nuklaivm-unit-tests]
steps:
- name: Finished NuklaiVM tests
run: echo "Finished NuklaiVM tests"

nuklaivm-load-tests:
needs: [nuklaivm-unit-tests]
strategy:
matrix:
level: [v1, v2, v3] # v4 is not supported
runs-on: ubuntu-20.04-32
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: ./.github/actions/install-go
with:
cache-dependency-path: |
go.sum
- name: Run load tests
shell: bash
run: GOAMD64=${{ matrix.level }} scripts/tests.load.sh

nuklaivm-sync-tests:
needs: [nuklaivm-unit-tests]
runs-on: ubuntu-20.04-32
timeout-minutes: 25
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: ./.github/actions/install-go
with:
cache-dependency-path: |
go.sum
- name: Run sync tests
shell: bash
run: scripts/run.sh
env:
MODE: 'full-test'

nuklaivm-wallet-release:
needs: [nuklaivm-load-tests, nuklaivm-sync-tests]
runs-on: macos-latest-xl
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: ./.github/actions/nuklai-wallet-release

nuklaivm-release:
needs: [nuklaivm-load-tests, nuklaivm-sync-tests]
# We build with 20.04 to maintain max compatibility: https://github.com/golang/go/issues/57328
runs-on: ubuntu-20.04-32
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: ./.github/actions/vm-release
with:
vm-name: nuklaivm
github-token: ${{ secrets.GITHUB_TOKEN }}
Loading

0 comments on commit 3bd7182

Please sign in to comment.