From 25c1b66fa7a1b09e7cd30b6420a7df966626a710 Mon Sep 17 00:00:00 2001 From: Tomoya Tanjo Date: Fri, 19 Mar 2021 09:37:02 +0000 Subject: [PATCH] Update CI settings --- .github/workflows/conformance.yml | 4 +-- Dockerfile | 13 ++++---- .../extensions/cwl-metrics/bin/isAWorkflow | 22 +++++++++++++ lib/ep3/extensions/cwl-metrics/extension.yml | 33 ++++++++++++++----- 4 files changed, 56 insertions(+), 16 deletions(-) create mode 100755 lib/ep3/extensions/cwl-metrics/bin/isAWorkflow diff --git a/.github/workflows/conformance.yml b/.github/workflows/conformance.yml index dc81df3..b5e8fde 100644 --- a/.github/workflows/conformance.yml +++ b/.github/workflows/conformance.yml @@ -45,8 +45,8 @@ jobs: curl -SL https://github.com/tom-tan/medal-hook/releases/download/${medal_hook_ver}/medal-hook-linux-x86_64.tar.gz \ | sudo tar xC /usr/bin env: - medal_ver: v0.4.0 - medal_hook_ver: v0.0.7 + medal_ver: v0.4.3 + medal_hook_ver: v0.1.1 - uses: actions/setup-node@v2 with: node-version: '14.x' diff --git a/Dockerfile b/Dockerfile index f49dc31..30c446b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,16 +2,17 @@ FROM alpine:3.13.0 LABEL maintainer="Tomoya Tanjo " -ARG medal_ver=v0.4.0 -ARG medal_hook_ver=v0.0.7 +ARG medal_ver=v0.4.3 +ARG medal_hook_ver=v0.1.1 -RUN apk --no-cache add ruby ruby-json ruby-etc nodejs jq docker-cli \ - ruby-irb ruby-webrick bash curl && \ +RUN echo "@testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \ + apk --no-cache add ruby ruby-json ruby-etc nodejs jq docker-cli \ + ruby-irb ruby-webrick bash curl \ + telegraf util-linux fluent-bit@testing && \ curl -SL https://github.com/tom-tan/medal/releases/download/${medal_ver}/medal-linux-x86_64.tar.gz \ | tar xC /usr/bin && \ curl -SL https://github.com/tom-tan/medal-hook/releases/download/${medal_hook_ver}/medal-hook-linux-x86_64.tar.gz \ - | tar xC /usr/bin && \ - apk del --purge curl + | tar xC /usr/bin COPY . /ep3 diff --git a/lib/ep3/extensions/cwl-metrics/bin/isAWorkflow b/lib/ep3/extensions/cwl-metrics/bin/isAWorkflow new file mode 100755 index 0000000..5708b58 --- /dev/null +++ b/lib/ep3/extensions/cwl-metrics/bin/isAWorkflow @@ -0,0 +1,22 @@ +#!/usr/bin/env ruby +require 'optparse' +require_relative "#{ENV['EP3_LIBPATH']}/runtime/inspector" + +if $0 == __FILE__ + opt = OptionParser.new + opt.banner = "#{$0} [options] " + opt.parse!(ARGV) + + unless ARGV.length == 1 + puts opt.help + exit + end + + dir = File.dirname(ARGV.first) + cwl = File.join(dir, 'job.cwl') + + unless walk(cwl, '.class', '') == 'Workflow' + puts 'It only supports a simple workflow' + exit 1 + end +end diff --git a/lib/ep3/extensions/cwl-metrics/extension.yml b/lib/ep3/extensions/cwl-metrics/extension.yml index d4d59cf..c382aba 100644 --- a/lib/ep3/extensions/cwl-metrics/extension.yml +++ b/lib/ep3/extensions/cwl-metrics/extension.yml @@ -6,6 +6,7 @@ hooks: - which fluent-bit > /dev/null - which uuidgen > /dev/null - curl -s $ES_HOST:$ES_PORT > /dev/null + - ./bin/isAWorkflow ~(target) operations: - type: replace-env env: @@ -24,7 +25,7 @@ hooks: - type: add-out target: to-fullpath-object out: - - place: ready-to-start-telegraf + - place: ready-to-collect pattern: 1 - type: add-transitions @@ -48,24 +49,40 @@ hooks: "${ES_HOST}:${ES_PORT}/workflow/_doc/${uuid}?pretty" \ --data-binary @"~(cwl.metrics.json)" > /dev/null transitions: + - name: prepare-metrics-directory + type: shell + in: + - place: ready-to-collect + pattern: _ + out: + - place: ready-to-start-telegraf + pattern: 1 + - place: ready-to-start-fluent-bit + pattern: 1 + command: mkdir -p $MEDAL_TMPDIR/metrics - name: keep-collecting-metrics type: shell in: - place: ready-to-start-telegraf pattern: _ out: - - place: fluent-bit.log - pattern: FILE - place: telegraf.log pattern: STDERR command: | - mkdir -p $MEDAL_TMPDIR/metrics - fluent-bit -c $EP3_EXT_PATH/cwl-metrics/conf/fluent-bit.conf \ - --log_file=~(fluent-bit.log)& telegraf_ver=$(telegraf --version | awk '{ print $2}') env TELEGRAF_VERSION=$telegraf_ver \ - telegraf --config $EP3_EXT_PATH/cwl-metrics/conf/telegraf.conf& - wait + telegraf --config $EP3_EXT_PATH/cwl-metrics/conf/telegraf.conf + - name: keep-sending-metrics + type: shell + in: + - place: ready-to-start-fluent-bit + pattern: _ + out: + - place: fluent-bit.log + pattern: FILE + command: | + fluent-bit -c $EP3_EXT_PATH/cwl-metrics/conf/fluent-bit.conf \ + --log_file=~(fluent-bit.log) - type: add-out target: workflow out: