Skip to content
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
21 changes: 2 additions & 19 deletions .github/awsl-layer-docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,12 @@
FROM lambci/lambda:20200812-build-ruby2.7 as builder
FROM public.ecr.aws/sam/build-ruby:3.4 AS builder

ARG INTERSCRIPT_GEM_VERSION
RUN echo "using INTERSCRIPT_GEM_VERSION=$INTERSCRIPT_GEM_VERSION"

ADD Gemfile .
RUN bundle config set path "/vendor"
RUN bundle install --without=development --jobs 4 --retry 3
#RUN ls -all /venfor/ruby/2.7.0/bundler/gems
# RUN echo "install python libs"

#RUN PYTHONUSERBASE=/lambda/lib/python3.7 pip3 install --user install \
# setuptools \
# numpy \
# git+https://github.com/sequitur-g2p/sequitur-g2p@9b7c505
FROM public.ecr.aws/sam/build-ruby:3.4 AS yumda

# ruby/gems/2.7.0/gems
FROM lambci/yumda:2 as yumda

#RUN yum install -y \
# python3 \
# pip3 \
# swig \
# python3-setuptools

#COPY --from=builder /lambda/ /lambda/
#COPY --from=builder /ruby/2.7.0 /lambda/opt/ruby/gems/2.7.0
COPY --from=builder /vendor/ruby /lambda/opt/ruby/gems/

10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
- package-ecosystem: bundler
directory: "/"
schedule:
interval: weekly
12 changes: 4 additions & 8 deletions .github/lambda/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
FROM lambci/lambda:20200812-build-ruby2.7 as builder
FROM public.ecr.aws/sam/build-ruby:3.4 AS builder

ARG INTERSCRIPT_GEM_VERSION
RUN echo "using INTERSCRIPT_GEM_VERSION=$INTERSCRIPT_GEM_VERSION"

COPY src .
ENV INTERSCRIPT_GEM_VERSION=${INTERSCRIPT_GEM_VERSION}
ENV GEM_HOME=${LAMBDA_TASK_ROOT}
#RUN echo $LAMBDA_TASK_ROOT
#RUN bundle config set path "/vendor"
RUN bundle install --without=development --jobs 4 --retry 3


FROM public.ecr.aws/lambda/ruby:2.7
FROM public.ecr.aws/lambda/ruby:3.4

ARG INTERSCRIPT_GEM_VERSION
RUN echo "using INTERSCRIPT_GEM_VERSION=$INTERSCRIPT_GEM_VERSION"
Expand All @@ -23,8 +22,5 @@ ENV INTERSCRIPT_GEM_VERSION=${INTERSCRIPT_GEM_VERSION}

COPY --from=builder ${LAMBDA_TASK_ROOT} ${LAMBDA_TASK_ROOT}
COPY src ${LAMBDA_TASK_ROOT}
#COPY --from=builder /vendor/ruby/2.7.0/gems ${LAMBDA_TASK_ROOT}/gems
#COPY --from=builder /vendor/ruby/2.7.0/gems /var/lang/lib/ruby/gems/2.7.0/gems
# /var/lang/lib/ruby/gems/2.7.0/gems
# COPY --from=builder /vendor/ruby /var/task/opt/ruby/gems/

CMD [ "lib/interscript-api/lambda_function.handler" ]
27 changes: 27 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: codeql

on:
push:
branches: [main]
pull_request:
schedule:
- cron: "0 0 * * 0" # weekly

permissions:
actions: read
contents: read
security-events: write

jobs:
analyze:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language: [ruby]
steps:
- uses: actions/checkout@v7
- uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
- uses: github/codeql-action/analyze@v3
4 changes: 2 additions & 2 deletions .github/workflows/manual-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: clone it
uses: actions/checkout@v2
uses: actions/checkout@v7
with:
submodules: true

Expand All @@ -39,7 +39,7 @@ jobs:
echo "API_TAG_NAME=$API_TAG_NAME" >> ${GITHUB_ENV}

- name: make new release
uses: softprops/action-gh-release@v0.1.7
uses: softprops/action-gh-release@v3
with:
token: ${{ env.GITHUB_PUSH_TOKEN }}
tag_name: ${{env.API_TAG_NAME}}
Expand Down
135 changes: 30 additions & 105 deletions .github/workflows/on-api-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,42 +10,52 @@ env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

permissions:
contents: read
packages: write

jobs:
build-release:
runs-on: ubuntu-latest
# id=68949242 => interscript-ci user
if: ${{ github.event.release.author.id == 68949242 }} #contains(github.event.release.body, '#releaseed-by-ci')
if: ${{ github.event.release.author.id == 68949242 }}
steps:
- uses: actions/checkout@v2
- name: setup env vars
- uses: actions/checkout@v7

- name: Extract gem version from release body
run: |
RELEASE_BODY="${{github.event.release.body}}"
echo "RELEASE_BODY=$RELEASE_BODY" >> ${GITHUB_ENV}
RELEASE_TAG_NAME="${{github.event.release.tag_name}}"
echo "RELEASE_TAG_NAME=$RELEASE_TAG_NAME" >> ${GITHUB_ENV}
GEM_VERSION=$(echo "$RELEASE_BODY" | grep -Po '(?<=v)[^;]+')
echo "RELEASE_TAG_NAME=$RELEASE_TAG_NAME" >> ${GITHUB_ENV}
echo "GEM_VERSION=$GEM_VERSION" >> ${GITHUB_ENV}
echo "INTERSCRIPT_GEM_VERSION=$GEM_VERSION" >> ${GITHUB_ENV}

- name: prepare docker context
- name: Prepare docker context
working-directory: .github/lambda
run: |
bash build.sh
run: bash build.sh

- name: push to github package
uses: elgohr/Publish-Docker-Github-Action@master
- name: Log in to GHCR
uses: docker/login-action@v4
with:
workdir: .github/lambda
dockerfile: Dockerfile
tags: "latest,${{env.RELEASE_TAG_NAME}}"
registry: "docker.pkg.github.com"
name: "${{github.repository}}/awslambda-interscript-api"
username: "${{github.actor}}"
password: "${{env.GITHUB_PUSH_TOKEN}}"
buildargs: INTERSCRIPT_GEM_VERSION
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ env.GITHUB_PUSH_TOKEN }}

- name: dispatch "infrastructure-lambda-api"
uses: peter-evans/repository-dispatch@v1
- name: Build and push Lambda image
uses: docker/build-push-action@v7
with:
context: .github/lambda
file: .github/lambda/Dockerfile
push: true
build-args: |
INTERSCRIPT_GEM_VERSION=${{ env.GEM_VERSION }}
tags: |
ghcr.io/${{ github.repository }}/awslambda-interscript-api:latest
ghcr.io/${{ github.repository }}/awslambda-interscript-api:${{ env.RELEASE_TAG_NAME }}

- name: Dispatch "infrastructure-lambda-api"
uses: peter-evans/repository-dispatch@v4
with:
token: ${{ env.GITHUB_PUSH_TOKEN }}
repository: interscript/infrastructure-lambda-api
Expand All @@ -55,88 +65,3 @@ jobs:
"workflow": "publish-ecr.yml",
"api_tag_name": "${{env.RELEASE_TAG_NAME}}"
}

# - name: setup-aws-credentials
# uses: aws-actions/configure-aws-credentials@v1
# with:
# aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }}
# aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }}
# aws-region: us-east-1
#
# - name: ecr-login
# id: login-ecr
# uses: aws-actions/amazon-ecr-login@v1
#
# - name: push to ecr
# env:
# ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
# working-directory: .github/lambda
# run: |
# docker build -t $ECR_REGISTRY/interscript-api:${{env.RELEASE_TAG_NAME}} .
# docker push $ECR_REGISTRY/$ECR_REPOSITORY:${{env.RELEASE_TAG_NAME}}




# - name: push to github package
# uses: elgohr/Publish-Docker-Github-Action@master
# with:
# workdir: .github/lambda
# dockerfile: Dockerfile
# tags: "latest,${{env.RELEASE_TAG_NAME}}"
# registry: ""
# name: "awslambda-interscript-api"
# username: "${{env.AWS_ACCESS_KEY_ID}}"
# password: "${{env.}}"
# buildargs: INTERSCRIPT_GEM_VERSION

# - name: login github package
# uses: docker/login-action@v1
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
# - name: build and push
# id: docker_build
# uses: docker/build-push-action@v2
# with:
# push: true
# tags: user/app:latest

# - name: setup ruby+install
# uses: ruby/setup-ruby@v1.75.0
# with:
# bundler-cache: false
# ruby-version: 2.7

# - name: build "-api" source
# working-directory: git
# run: |
# cp Gemfile* lib/
# zip -r ${AWSL_SRC_ZIP} lib

# - name: build "-layer"
# working-directory: git/.github/awsl-layer-docker
# run: |
# ls -all
# bash build.sh
# cp libs.zip $AWSL_LAYER_ZIP

# - name: upload lambda layer to current release
# uses: softprops/action-gh-release@v1
# with:
# tag_name: ${{env.RELEASE_TAG_NAME}}
# files: |
# ${{env.AWSL_SRC_ZIP}}
# ${{env.AWSL_LAYER_ZIP}}

# - name: dispatch "infrastructure-lambda-api"
# uses: peter-evans/repository-dispatch@v1
# with:
# token: ${{ env.GITHUB_PUSH_TOKEN }}
# repository: interscript/infrastructure-lambda-api
# event-type: ${{ github.repository }}
# client-payload: >-
# {
# "workflow": "on-api-release.yml",
# "api_tag_name": "${{env.RELEASE_TAG_NAME}}"
# }
22 changes: 0 additions & 22 deletions .github/workflows/on-interscript-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,9 @@ on:
repository_dispatch:
types: [ interscript/interscript ]

env:
GITHUB_PUSH_TOKEN: ${{ secrets.INTERSCRIPT_CI_PAT }}

jobs:
create-release:
runs-on: ubuntu-latest
if: startsWith(github.event.client_payload.ref, 'refs/tags/v')
steps:
- run: echo "disabled for now"
# - uses: actions/checkout@v1
#
# - name: Setup env-vars
# run: |
# REF="${{ github.event.client_payload.ref }}"
# INTERSCRIPT_VERSION=${REF#refs/*/v}
# echo "INTERSCRIPT_VERSION=$INTERSCRIPT_VERSION" >> $GITHUB_ENV
# echo "API_TAG_NAME=$INTERSCRIPT_VERSION" >> $GITHUB_ENV
#
# - name: Create API Release
# uses: actions/create-release@v1
# with:
# token: ${{ env.GITHUB_PUSH_TOKEN }}
# tag_name: v${{env.API_TAG_NAME}}
## release_name: Release v${{env.INTERSCRIPT_VERSION}}
## body: Auto release API v${{env.INTERSCRIPT_VERSION}} by @interscript-ci
# body: "#release-by-ci for Interscript Gem v${{env.INTERSCRIPT_VERSION}}"
# draft: false
# prerelease: false
33 changes: 33 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: test

on:
push:
branches: [main]
pull_request:

jobs:
rspec:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby: ["3.4"] # Ruby 4.0 readiness: target latest stable 3.x line
env:
INTERSCRIPT_GEM_VERSION: "0.1.9"
steps:
- uses: actions/checkout@v7
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- run: bundle exec rspec
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed

standard:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium test

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Comment on lines +10 to +25
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4"
bundler-cache: true
- run: bundle exec standardrb

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium test

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
Comment on lines +26 to +33
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7
3.4.8
3 changes: 3 additions & 0 deletions .standard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ignore:
- "vendor/**/*"
- "tmp/**/*"
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Changelog

All notable changes to this project are documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [Latest]

See GitHub releases for detailed release notes: https://github.com/interscript/interscript-api/releases
Loading
Loading