Skip to content

Commit

Permalink
chore(cicd): add dev yml template (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
j-luong authored Jul 9, 2024
1 parent 90955e0 commit 6083615
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .generated
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-06-28T14:16:01+01:00
2024-07-09T12:32:18+01:00
67 changes: 48 additions & 19 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# +-----------------------------------------------+
# | WARNING: This file is generated, do not edit! |
# | Edit _templates/dev.yml.erb instead. |
# +-----------------------------------------------+

name: Dev

on:
on:
push:
branches-ignore:
- master
- master

jobs:
lint:
Expand Down Expand Up @@ -43,14 +48,14 @@ jobs:
- base: elixir
tag: elixir
target: linux
- base: elixir:1.12
tag: elixir-1.12
- base: elixir:1.10
tag: elixir-1.10
target: linux
- base: elixir:1.11
tag: elixir-1.11
target: linux
- base: elixir:1.10
tag: elixir-1.10
- base: elixir:1.12
tag: elixir-1.12
target: linux
- base: golang
tag: golang
Expand Down Expand Up @@ -91,27 +96,42 @@ jobs:
- base: gradle:jdk19
tag: gradle-jdk19
target: linux
- base: gradle:jdk20
tag: gradle-jdk20
target: linux
- base: gradle:jdk21
tag: gradle-jdk21
target: linux
- base: gradle:jdk8
tag: gradle-jdk8
target: linux
- base: maven
tag: maven
target: linux
- base: maven:3-jdk-11
tag: maven-3-jdk-11
target: linux
- base: maven:3-eclipse-temurin-17
tag: maven-3-jdk-17
target: linux
- base: maven:3-eclipse-temurin-20
tag: maven-3-jdk-20
target: linux
- base: maven:3-eclipse-temurin-21
tag: maven-3-jdk-21
target: linux
- base: maven:3-eclipse-temurin-22
tag: maven-3-jdk-22
target: linux
- base: maven:3-jdk-11
tag: maven-3-jdk-11
target: linux
- base: maven:3-jdk-8
tag: maven-3-jdk-8
target: linux
- base: mcr.microsoft.com/dotnet/core/sdk
tag: dotnet
target: linux
- base: mcr.microsoft.com/dotnet/sdk:8.0
tag: dotnet-8.0
target: linux
- base: node
tag: node
target: linux
Expand All @@ -121,21 +141,33 @@ jobs:
- base: node:20
tag: node-20
target: linux
- base: node:22
tag: node-22
target: linux
- base: python
tag: python
target: linux
- base: python:3.8
tag: python-3.8
target: linux
- base: python:3.9-rc
- base: python:3.9
tag: python-3.9
target: linux
- base: python:3.10
tag: python-3.10
target: linux
- base: python:3.11
tag: python-3.11
target: linux
- base: ruby
tag: ruby
target: linux
- base: ruby:3.3
tag: ruby-3.3
target: linux
- base: swift
tag: swift
target: linux
- base: ubuntu
tag: linux
target: linux
Expand All @@ -145,20 +177,17 @@ jobs:
- base: alpine
tag: cocoapods
target: alpine
- base: alpine
tag: swift
target: alpine
- base: composer
tag: composer
target: alpine
- base: composer
tag: php
target: alpine
- base: docker:latest
tag: docker-latest
tag: docker
target: alpine
- base: docker:latest
tag: docker
tag: docker-latest
target: alpine
- base: python:alpine
tag: python-alpine
Expand All @@ -168,7 +197,7 @@ jobs:
target: alpine
steps:
- uses: actions/checkout@v2

- name: Build all images
uses: docker/build-push-action@v2
with:
Expand All @@ -179,10 +208,10 @@ jobs:
build-args: |
IMAGE=${{ matrix.base }}
TAG=${{ matrix.tag }}
- name: Show images
run: docker image ls

- name: Install npm dependencies
run: npm install

Expand All @@ -191,7 +220,7 @@ jobs:
env:
SNYK_TOKEN: ${{secrets.SNYK_TOKEN}}
IMAGE_TAG: ${{ matrix.tag }}

# Select tests against specific images
image-specific-tests:
needs: [lint]
Expand Down
91 changes: 91 additions & 0 deletions _templates/dev.yml.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# +-----------------------------------------------+
# | WARNING: This file is generated, do not edit! |
# | Edit _templates/dev.yml.erb instead. |
# +-----------------------------------------------+

name: Dev

on:
push:
branches-ignore:
- master

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install npm dependencies
run: npm install

- name: Lint - check formatting
run: npm run lint:formatting

# run a common set of tests against ALL images
smoke-tests:
needs: [lint]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
base:
- <%= @seed[0] %>
tag:
- <%= @seed[1] %>
target:
- <%= @seed[2] %>
include:<% @images.each do |base,tag,target| %>
- base: <%= base %>
tag: <%= tag %>
target: <%= target %><% end %>
steps:
- uses: actions/checkout@v2

- name: Build all images
uses: docker/build-push-action@v2
with:
push: false
tags: ${{ matrix.tag }}
file: Dockerfile
target: ${{ matrix.target }}
build-args: |
IMAGE=${{ matrix.base }}
TAG=${{ matrix.tag }}

- name: Show images
run: docker image ls

- name: Install npm dependencies
run: npm install

- name: Run tests
run: npm run test:smoke
env:
SNYK_TOKEN: ${{secrets.SNYK_TOKEN}}
IMAGE_TAG: ${{ matrix.tag }}

# Select tests against specific images
image-specific-tests:
needs: [lint]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build `python-3.8` image for test
uses: docker/build-push-action@v2
with:
push: false
tags: python-3.8
file: Dockerfile
target: linux
build-args: |
IMAGE=python:3.8
TAG=python-3.8
- name: Show images
run: docker image ls
- name: Install npm dependencies
run: npm install
- name: Run tests
run: npx jest test/image-specific/python-3-poetry.spec.ts
env:
SNYK_TOKEN: ${{secrets.SNYK_TOKEN}}
10 changes: 10 additions & 0 deletions build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@
# Everything else is used as explicitly included jobs.
@seed = @images.shift

# Generate the dev.yml
templatename = File.join("_templates", "dev.yml.erb")
renderer = ERB.new(File.read(templatename))
File.open(".github/workflows/dev.yml", "w") { |file| file.puts renderer.result() }

# We need to write a file to trigger the image build action, as just changing the
# contents of workflow doesn't trigger it
File.open(".generated", "w") { |file| file.puts DateTime.now.iso8601 }

# Generate the build.yml
templatename = File.join("_templates", "build.yml.erb")
renderer = ERB.new(File.read(templatename))
File.open(".github/workflows/build.yml", "w") { |file| file.puts renderer.result() }
Expand Down

0 comments on commit 6083615

Please sign in to comment.