Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
auricom committed Sep 24, 2024
1 parent ccd149b commit 837fb7d
Show file tree
Hide file tree
Showing 9 changed files with 168 additions and 36 deletions.
2 changes: 2 additions & 0 deletions .github/scripts/prepare-matrices.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def get_app_metadata(subdir, meta, forRelease=False, channels=None):
toBuild["path"] = meta["path"]
toBuild["branch"] = channel["branch"]
toBuild["update_modules"] = channel["update_modules"]
toBuild["build_command"] = meta["build_command"]
toBuild["build_artifacts"] = meta["build_artifacts"]

# Container Tags
Expand Down Expand Up @@ -84,6 +85,7 @@ def get_app_metadata(subdir, meta, forRelease=False, channels=None):

platformToBuild["tests_enabled"] = channel["tests"]["enabled"] and platform in TESTABLE_PLATFORMS

platformToBuild["build_command"] = toBuild["build_command"]
platformToBuild["build_artifacts"] = meta["build_artifacts"]
platformToBuild["update_modules"] = channel["update_modules"]

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ on:
required: false
type: boolean
default: false
pushImages:
publishArtifacts:
required: false
type: boolean
default: false
sendNotifications:
required: false
default: false
type: boolean
push:

jobs:

prepare:
name: Prepare to Build
runs-on: ubuntu-latest
Expand All @@ -32,12 +32,12 @@ jobs:
shell: bash
run: echo "LOWERCASE_REPO_OWNER=${GITHUB_REPOSITORY_OWNER,,}" >> $GITHUB_ENV

- name: Generate Token
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: "${{ secrets.BOT_APP_ID }}"
private-key: "${{ secrets.BOT_APP_PRIVATE_KEY }}"
# - name: Generate Token
# uses: actions/create-github-app-token@v1
# id: app-token
# with:
# app-id: "${{ secrets.BOT_APP_ID }}"
# private-key: "${{ secrets.BOT_APP_PRIVATE_KEY }}"

- name: Checkout
uses: actions/checkout@v4
Expand All @@ -60,43 +60,42 @@ jobs:
TOKEN: ${{ steps.app-token.outputs.token }}
shell: bash
run: |
set -x
if [[ -z "${{ inputs.appsToBuild }}" ]]; then
matrices=$(python ./.github/scripts/prepare-matrices.py "all" "${{ inputs.pushImages }}")
matrices=$(python ./.github/scripts/prepare-matrices.py "all" "${{ inputs.publishArtifacts }}")
else
if [[ -z "${{ inputs.channelsToBuild }}" ]]; then
matrices=$(python ./.github/scripts/prepare-matrices.py "${{ inputs.appsToBuild }}" "${{ inputs.pushImages }}")
else
matrices=$(python ./.github/scripts/prepare-matrices.py "${{ inputs.appsToBuild }}" "${{ inputs.pushImages }}" "${{ inputs.channelsToBuild }}")
fi
matrices=$(python ./.github/scripts/prepare-matrices.py "${{ inputs.appsToBuild }}" "${{ inputs.publishArtifacts }}")
fi
echo "matrices=${matrices}" >> $GITHUB_OUTPUT
echo "${matrices}"
build-app:
runs-on: ubuntu-latest
build-platform-app:
name: Build/Test ${{ matrix.app.name }} (${{ matrix.app.platform }})
needs: prepare
if: ${{ toJSON(fromJSON(needs.prepare.outputs.matrices).app) != '[]' && toJSON(fromJSON(needs.prepare.outputs.matrices).app) != '' }}
runs-on: ubuntu-latest
if: ${{ toJSON(fromJSON(needs.prepare.outputs.matrices).appPlatforms) != '[]' && toJSON(fromJSON(needs.prepare.outputs.matrices).appPlatforms) != '' }}
outputs:
date: ${{ steps.archive.outputs.date }}
strategy:
fail-fast: false
matrix:
go-arch: [amd64, arm64]
app: "${{ fromJSON(needs.prepare.outputs.matrices).app }}"
app: "${{ fromJSON(needs.prepare.outputs.matrices).appPlatforms }}"
permissions:
contents: read
packages: write
steps:
- name: Log Matrix Input
shell: bash
run: |
cat << EOF
${{ toJSON(matrix.image)}}
${{ toJSON(matrix.app)}}
EOF
- uses: actions/checkout@v4
with:
repository: cosmos/cosmos-sdk
ref: ${{ matrix.major-version == 'main' && 'main' || format('refs/heads/release/{0}', matrix.major-version) }}
repository: ${{ matrix.app.repository }}
ref: ${{ matrix.app.branch }}
token: ${{ github.token }}
path: cosmos-sdk
path: ${{ matrix.app.repository }}

- uses: actions/checkout@v4
with:
Expand All @@ -107,26 +106,42 @@ jobs:
go-version: "1.23"
check-latest: true

- name: Download go.mod and go.sum
uses: actions/download-artifact@v4
if: ${{ inputs.depsUpdate }}
with:
name: go-files-${{ matrix.major-version }}
path: cosmos-sdk/simapp
- name: Update go modules
# Disable dependencies updates for v0.52.x
if: matrix.major-version != 'v0.52.x'
run: |
set -x
ls -l
ls -l ../
ls -l ../../
cd ${{ matrix.app.repository }}/${{ matrix.app.path }}
COSMOSSDK_BRANCH=${{ matrix.app.branch }} ../../nightly-stack/.github/scripts/update-go-modules.sh
- name: show output of modified go.sum and go.mod
run: |
echo "############"
echo "# go.mod"
echo "############"
cat ${{ matrix.app.repository }}/${{ matrix.app.path }}/go.mod
echo -e "\n\n"
echo "############"
echo "# go.mod"
echo "############"
cat ${{ matrix.app.repository }}/${{ matrix.app.path }}/go.sum
- name: Create application binary
id: build
run: |
cd cosmos-sdk/simapp
cd ${{ matrix.app.repository }}/${{ matrix.app.path }}
go mod tidy
cd ../
GOARCH=${{ matrix.go-arch }} make install
GOARCH=${{ matrix.app.target_arch }} ${{ matrix.app.build_command }}
echo "gobin=$(go env GOPATH)/bin" >> $GITHUB_OUTPUT
- name: Run and monitor application
shell: bash
# no arm64 runners as of now : https://github.com/orgs/community/discussions/19197
if: ${{ matrix.go-arch == 'amd64' }}
if: ${{ matrix.app.target_arch == 'amd64' }}
run: |
set -oue pipefail
set -x
Expand Down Expand Up @@ -189,7 +204,7 @@ jobs:
with:
registry: ghcr.io
username: "${{ github.actor }}"
password: "${{ secrets.GI THUB_TOKEN }}"
password: "${{ secrets.GITHUB_TOKEN }}"

- name: Setup Goss
if: ${{ matrix.go-arch == 'amd64' }}
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/nightlies-scheduled.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Scheduled Nightlies

concurrency:
group: nightlies
cancel-in-progress: false

on:
workflow_dispatch:
inputs:
appsToBuild:
description: App(s) to build
required: false
type: string
default: all
schedule:
- cron: "0 0 * * *"

jobs:
simple-checks:
name: Simple Checks
uses: .github/workflows/simple-checks.yaml

build-images:
name: Build Images
needs: simple-checks
uses: .github/workflows/build-applications.yaml
secrets: inherit
permissions:
contents: read
packages: write
with:
appsToBuild: ${{ inputs.appsToBuild }}
publishArtifacts: true
sendNotifications: true

# render-readme:
# name: Render Readme
# needs: build-images
# uses: ./.github/workflows/render-readme.yaml
# secrets: inherit
38 changes: 38 additions & 0 deletions .github/workflows/simple-checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: "Simple Checks"

on:
workflow_call:

jobs:
metadata-validation:
name: Validate App Metadata
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get Changed Files
id: changed-files
uses: tj-actions/changed-files@v45
with:
files_yaml: |
cue:
- metadata.rules.cue
- apps/**/metadata.json
- apps/**/metadata.yaml
- name: Setup CUE
if: ${{ steps.changed-files.outputs.cue_any_changed == 'true' }}
uses: cue-lang/[email protected]

# Run against all files to ensure they are tested if the cue schema is changed.
- name: Validate image metadata
if: ${{ steps.changed-files.outputs.cue_any_changed == 'true' }}
shell: bash
run: |
find ./apps/ -name metadata.json | xargs -I {} cue vet --schema '#Spec' {} ./metadata.rules.cue
find ./apps/ -name metadata.yaml | xargs -I {} cue vet --schema '#Spec' {} ./metadata.rules.cue
14 changes: 14 additions & 0 deletions apps/cosmos-sdk-comet/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
app: cosmos-sdk
repository: cosmos/cosmos-sdk
path: simapp
build_command: make install
build_artifacts: true
channels:
- name: main
platforms: ["linux/amd64","linux/arm64"]
branch: main
update_modules: false
tests:
enabled: true
type: web
3 changes: 2 additions & 1 deletion apps/cosmos-sdk/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
app: cosmos-sdk
repository: github.com/cosmos/cosmos-sdk
repository: cosmos/cosmos-sdk
path: simapp
build_command: make install
build_artifacts: true
channels:
- name: main
Expand Down
3 changes: 2 additions & 1 deletion apps/ibc-go/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
app: ibc-go
repository: github.com/cosmos/ibc-go
repository: cosmos/ibc-go
path: simapp
build_command: make build
build_artifacts: true
channels:
- name: main
Expand Down
19 changes: 19 additions & 0 deletions metadata.rules.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#Spec: {
app: #AppName
semver?: bool
channels: [...#Channels]
}

#Channels: {
name: #ChannelName
platforms: [...#Platforms]
stable: bool
tests: {
enabled: bool
type?: =~"^(cli|web)$"
}
}

#AppName: string & !="" & =~"^[a-zA-Z0-9_-]+$"
#ChannelName: string & !="" & =~"^[a-zA-Z0-9._-]+$"
#Platforms: "linux/amd64" | "linux/arm64"

0 comments on commit 837fb7d

Please sign in to comment.