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

ci: start Docker image and test output #110

Merged
merged 18 commits into from
Apr 26, 2023
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
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
modules
npm-debug.log
62 changes: 62 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,65 @@ jobs:
- run: npm run test:lint
if: matrix.os != 'windows-latest'
- run: npm run test:unit

docker:
name: Build and test Docker
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
env:
REGISTRY: ghcr.io

steps:
- uses: actions/checkout@v3

- uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: "arm64"

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build and load Docker image
id: docker_build
uses: docker/build-push-action@v4
with:
context: .
load: true
tags: core-test
cache-from: type=registry,ref=ghcr.io/filecoin-station/core
cache-to: type=inline

- name: Build Docker image for other platforms
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/arm64
cache-from: type=registry,ref=ghcr.io/filecoin-station/core
cache-to: type=inline

- name: Start Station Core container
run: |
docker run \
--name station \
--detach \
--env FIL_WALLET_ADDRESS=f1abjxfbp274xpdqcpuaykwkfb43omjotacm2p3za \
$IMAGEID
env:
IMAGEID: ${{ steps.docker_build.outputs.imageid }}

- name: Print station activity
run: |
sleep 10 # Wait for Station modules to start
docker exec station bin/station.js activity

- name: Check | Saturn started
run: docker exec station bin/station.js activity | grep "Saturn module started"
bajtos marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 2 additions & 3 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: Docker build
on:
push:
tags: ["*"]
branches: ["*"]

env:
REGISTRY: ghcr.io
Expand Down Expand Up @@ -35,11 +34,11 @@ jobs:
- uses: martinbeentjes/npm-get-version-action@main
id: package-version

- name: Build and optionally push Docker image
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: ${{ startsWith(github.ref, 'refs/tags/v') }}
push: true
tags: |
ghcr.io/filecoin-station/core
ghcr.io/filecoin-station/core:${{ steps.package-version.outputs.current-version }}
Expand Down
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ FROM node:18-alpine
LABEL org.opencontainers.image.source https://github.com/filecoin-station/core
USER node
WORKDIR /usr/src/app
COPY package*.json ./
COPY scripts/post-install.js ./scripts/
RUN npm ci --omit=dev
COPY . .
RUN npm ci --omit=dev
CMD [ "./bin/station.js" ]
2 changes: 1 addition & 1 deletion bin/station.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ yargs(hideBin(process.argv))
commands.activity
)
.command('logs [module]', 'Show module logs', () => {}, commands.logs)
.choices('module', ['saturn-l2-node'])
.choices('module', modules)
bajtos marked this conversation as resolved.
Show resolved Hide resolved
.version(`${pkg.name}: ${pkg.version}`)
.alias('v', 'version')
.alias('h', 'help')
Expand Down
10 changes: 5 additions & 5 deletions lib/saturn-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import { fetch } from 'undici'
import * as Sentry from '@sentry/node'
import { installBinaryModule, getBinaryModuleExecutable } from './modules.js'

const DIST_TAG = 'v0.5.0'
const DIST_TAG = 'v0.5.1'

export async function install () {
await installBinaryModule({
module: 'saturn-l2-node',
module: 'saturn-L2-node',
repo: 'filecoin-saturn/L2-node',
distTag: DIST_TAG,
executable: 'L2-node',
executable: 'saturn-L2-node',
arch: platform() === 'darwin' ? 'x64' : arch(),
targets: [
{ platform: 'darwin', arch: 'x64', asset: 'L2-node_Darwin_x86_64.zip' },
Expand All @@ -36,8 +36,8 @@ async function start ({

const childProcess = execa(
getBinaryModuleExecutable({
module: 'saturn-l2-node',
executable: 'L2-node'
module: 'saturn-L2-node',
executable: 'saturn-L2-node'
}), {
env: {
ROOT_DIR: storagePath,
Expand Down
4 changes: 2 additions & 2 deletions test/metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ describe('Metrics', () => {
{ recursive: true }
)
await fs.writeFile(
join(getPaths(CACHE_ROOT, STATE_ROOT).metrics, 'saturn-l2-node.log'),
join(getPaths(CACHE_ROOT, STATE_ROOT).metrics, 'saturn-L2-node.log'),
'[date] {"totalJobsCompleted":1,"totalEarnings":"2"}\n'
)
const { stdout } = await execa(
station,
['metrics', 'saturn-l2-node'],
['metrics', 'saturn-L2-node'],
{ env: { CACHE_ROOT, STATE_ROOT } }
)
assert.deepStrictEqual(
Expand Down