Skip to content

Commit

Permalink
Add github actions and updats for standalone repo
Browse files Browse the repository at this point in the history
  • Loading branch information
MSevey committed May 26, 2022
1 parent 963d6bb commit 9b1110a
Show file tree
Hide file tree
Showing 10 changed files with 3,442 additions and 8 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: monthly
open-pull-requests-limit: 10
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: monthly
79 changes: 79 additions & 0 deletions .github/workflows/ci_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Release
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
# Inputs the workflow accepts.
inputs:
version:
# Friendly description to be shown in the UI instead of 'name'
description: "Semver type of new version (major / minor / patch)"
# Input has to be provided for the workflow to run
required: true
type: choice
options:
- patch
- minor
- major

jobs:
# Run the linting and tests
hadolint:
uses: SkynetLabs/.github/.github/workflows/reusable_dockerfile_lint.yml@master

check:
name: "Checks and Tests"
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
node-version: [14.x, 16.x, 18.x]

steps:
- name: "Run Yarn Basic Checks"
uses: SkynetLabs/.github/.github/actions/yarn-basic-checks@master
with:
node-version: ${{ matrix.node-version }}

tests:
name: "Jest Tests"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
with:
node-version: 16.x

- run: yarn
- run: yarn jest

# Make a release if this is a manually trigger job, i.e. workflow_dispatch
release:
needs: [hadolint, check, tests]
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' }}
outputs:
new_version: ${{ steps.version.outputs.new-version }}
steps:
- uses: actions/checkout@v3
- name: Version Release
id: version
uses: SkynetLabs/.github/.github/actions/version-release@master
with:
github-token: ${{secrets.GITHUB_TOKEN}}
version-bump: ${{github.event.inputs.version}}

docker:
needs: release
name: Build and Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- uses: SkynetLabs/.github/.github/actions/docker-publish@master
with:
docker_username: ${{ secrets.DOCKER_USERNAME}}
docker_password: ${{ secrets.DOCKER_PASSWORD}}
docker_repository: skynetlabs/webportal-health-check
semver_version: ${{ needs.release.outputs.new_version }}
71 changes: 71 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# 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: "32 21 * * 0"

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

strategy:
fail-fast: false
matrix:
language: ["javascript"]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

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

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
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.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

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

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
state/
node_modules/
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ ENV PATH="/usr/app/bin:${PATH}"
RUN echo '*/5 * * * * source /etc/environment ; /usr/app/bin/cli run critical >> /proc/1/fd/1' >> /etc/crontabs/root && \
echo '0 * * * * source /etc/environment ; /usr/app/bin/cli run extended >> /proc/1/fd/1' >> /etc/crontabs/root

COPY packages/health-check/package.json \
packages/health-check/yarn.lock \
COPY package.json \
yarn.lock \
./

RUN yarn --frozen-lockfile

COPY packages/health-check/src src
COPY packages/health-check/cli cli
COPY packages/health-check/bin bin
COPY src src
COPY cli cli
COPY bin bin

EXPOSE 3100
ENV NODE_ENV production
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[![Release](https://github.com/SkynetLabs/webportal-health-checks/actions/workflows/ci_release.yml/badge.svg)](https://github.com/SkynetLabs/webportal-health-checks/actions/workflows/ci_release.yml)
[![CodeQL](https://github.com/SkynetLabs/webportal-health-checks/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/SkynetLabs/webportal-health-checks/actions/workflows/codeql-analysis.yml)

# Webportal Health Check

This repo contains the health checks that are run on the Skynet Webportals
2 changes: 1 addition & 1 deletion bin/cli
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ require("yargs/yargs")(process.argv.slice(2))

const entry = {
date: new Date().toISOString(),
checks: (await Promise.all(checks.map((check) => new Promise(check)))).map(middleware),
checks: (await Promise.all(checks.map((check) => new Promise(check)))).filter(Boolean).map(middleware),
};

db.read() // read before writing to make sure no external changes are overwritten
Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,11 @@
"devDependencies": {
"jest": "^28.0.3",
"prettier": "^2.6.2"
},
"scripts": {
"lint": "yarn prettier --check .",
"format": "yarn prettier --write .",
"test": "echo 'Warning: no test script specified'",
"build": "echo 'Warning: no build script specified'"
}
}
5 changes: 3 additions & 2 deletions src/checks/critical.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ async function registryWriteAndReadCheck(done) {

// directServerApiAccessCheck returns the basic server api check on direct server address
async function directServerApiAccessCheck(done) {
if (!process.env.SERVER_DOMAIN) {
return done({ up: false, errors: [{ message: "SERVER_DOMAIN env variable not configured" }] });
// skip if SERVER_DOMAIN is not set or it equals PORTAL_DOMAIN (single server portals)
if (!process.env.SERVER_DOMAIN || process.env.SERVER_DOMAIN === process.env.PORTAL_DOMAIN) {
return done();
}

const [portalAccessCheck, serverAccessCheck] = await Promise.all([
Expand Down
Loading

0 comments on commit 9b1110a

Please sign in to comment.