Skip to content

Commit

Permalink
Merge pull request #18 from elijahr/fix-args
Browse files Browse the repository at this point in the history
Better dockerRunArgs handling, ensure slug is lowercase, add install parameter
  • Loading branch information
uraimo authored Sep 8, 2020
2 parents b17be6e + aa83d32 commit e89804c
Show file tree
Hide file tree
Showing 54 changed files with 941 additions and 71 deletions.
29 changes: 26 additions & 3 deletions .github/workflows/advanced-example.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
on: [push]
name: Advanced Example
on: [push, pull_request]

jobs:
build_job:
Expand Down Expand Up @@ -39,14 +40,36 @@ jobs:
# Pass some environment variables to the container
env: | # YAML, but pipe character is necessary
artifact_name: sh-${{ matrix.distro }}_${{ matrix.arch }}
artifact_name: git-${{ matrix.distro }}_${{ matrix.arch }}
# The shell to run commands with in the container
shell: /bin/sh

# Install some dependencies in the container. This speeds up builds if
# you are also using githubToken. Any dependencies installed here will
# be part of the container image that gets cached, so subsequent
# builds don't have to re-install them. The image layer is cached
# publicly in your project's package repository, so it is vital that
# no secrets are present in the container state or logs.
install: |
case "${{ matrix.distro }}" in
ubuntu*|jessie|stretch|buster)
apt-get update -q -y
apt-get install -q -y git
;;
fedora*)
dnf -y update
dnf -y install git which
;;
alpine*)
apk update
apk add git
;;
esac
# Produce a binary artifact and place it in the mounted volume
run: |
cp /bin/sh "/artifacts/${artifact_name}"
cp $(which git) "/artifacts/${artifact_name}"
echo "Produced artifact at /artifacts/${artifact_name}"
- name: Show the artifact
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/basic-example.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

on: [push]
name: Basic Example
on: [push, pull_request]

jobs:
armv7_job:
Expand Down
16 changes: 9 additions & 7 deletions .github/workflows/swift-build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: swift-build
on: [push,pull_request]
name: Build with Swift on armv7
on: [push, pull_request]

jobs:
testactions_job:
Expand All @@ -8,17 +8,19 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build with Swift on armv7
- name: Build
uses: ./
with:
arch: armv7
distro: ubuntu18.04
githubToken: ${{ github.token }}
run: |
export DEBIAN_FRONTEND=noninteractive
apt-get update -q
install: |
apt-get update -q -y
apt install -q -y libatomic1 libbsd0 clang libicu-dev libcurl4-nss-dev curl
curl -OL https://github.com/uraimo/buildSwiftOnARM/releases/download/5.0.3/swift-5.0.3-armv7-Ubuntu1804.tgz
curl -L https://github.com/uraimo/buildSwiftOnARM/releases/download/5.0.3/swift-5.0.3-armv7-Ubuntu1804.tgz -o /root/swift-5.0.3-armv7-Ubuntu1804.tgz
run: |
cd /root
tar xzf swift-5.0.3-armv7-Ubuntu1804.tgz
echo "import Glibc;puts(\"Test!\");print(\"Test!!\")" > test.swift
./usr/bin/swiftc test.swift
Expand Down
108 changes: 79 additions & 29 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: test
name: Unit Tests
on: [push, pull_request]

jobs:
Expand Down Expand Up @@ -38,41 +38,72 @@ jobs:
arch: ${{ matrix.arch }}
distro: ${{ matrix.distro }}
env: |
var_1: value_1
var_2: value_2
env_arch: ${{ matrix.arch }}
env_distro: ${{ matrix.distro }}
# Test multiple argument formats
dockerRunArgs: |
-v "${PWD}/volume_1:/volume_1"
-v "${PWD}/volume_2:/volume_2"
--volume=${PWD}/volume_2:/volume_2
"-v${PWD}/volume_3:/volume_3"
-v "${PWD}/volume_4:/volume_4" -v "${PWD}/volume_5:/volume_5"
# Sourced on host, after container build, before container run
setup: |
distro_info=$(cat /etc/*-release | tr '[:upper:]' '[:lower:]' | tr '"' ' ' | tr '\n' ' ')
echo ::set-output name=host_arch::$(uname -m)
echo ::set-output name=host_distro_info::$distro_info
echo ::set-output name=host_var_1::$var_1
echo ::set-output name=host_var_2::$var_2
echo ::set-output name=host_shell_options::$-
echo ::set-output name=host_arch::"$(uname -m)"
echo ::set-output name=host_distro_info::"$distro_info"
echo ::set-output name=host_env_arch::"$env_arch"
echo ::set-output name=host_env_distro::"$env_distro"
echo ::set-output name=host_shell_options::"$-"
# Setup volumes
mkdir "${PWD}/volume_1"
touch "${PWD}/volume_1/file_1"
mkdir "${PWD}/volume_2"
touch "${PWD}/volume_2/file_2"
mkdir "${PWD}/volume_3"
touch "${PWD}/volume_3/file_3"
mkdir "${PWD}/volume_4"
touch "${PWD}/volume_4/file_4"
mkdir "${PWD}/volume_5"
touch "${PWD}/volume_5/file_5"
# Install some dependencies in the container, to be cached in a docker
# image layer.
install: |
case "${{ matrix.distro }}" in
ubuntu*|jessie|stretch|buster)
apt-get update -q -y
apt-get install -q -y git
;;
fedora*)
dnf -y update
dnf -y install git which
;;
alpine*)
apk update
apk add git
;;
esac
# Run on container
run: |
distro_info=$(cat /etc/*-release | tr '[:upper:]' '[:lower:]' | sed 's/"//g' | tr '\n' ';')
echo ::set-output name=arch::$(uname -m)
echo ::set-output name=distro_info::$distro_info
echo ::set-output name=shebang::$(head -n 1 "$0")
echo ::set-output name=var_1::$var_1
echo ::set-output name=var_2::$var_2
echo ::set-output name=volume_1_ls::$(ls /volume_1 || true)
echo ::set-output name=volume_2_ls::$(ls /volume_2 || true)
echo ::set-output name=shell_options::$-
echo ::set-output name=arch::"$(uname -m)"
echo ::set-output name=distro_info::"$distro_info"
echo ::set-output name=shebang::"$(head -n 1 "$0")"
echo ::set-output name=env_arch::"$env_arch"
echo ::set-output name=env_distro::"$env_distro"
echo ::set-output name=volume_1_ls::"$(ls /volume_1 || true)"
echo ::set-output name=volume_2_ls::"$(ls /volume_2 || true)"
echo ::set-output name=volume_3_ls::"$(ls /volume_3 || true)"
echo ::set-output name=volume_4_ls::"$(ls /volume_4 || true)"
echo ::set-output name=volume_5_ls::"$(ls /volume_5 || true)"
echo ::set-output name=git_path::"$(which git)"
echo ::set-output name=shell_options::"$-"
- name: Assert setup script runs on host (check arch info)
run: |
Expand All @@ -90,14 +121,21 @@ jobs:
- name: Assert setup script receives environment variables
run: |
var_1="${{ steps.build.outputs.host_var_1 }}"
var_2="${{ steps.build.outputs.host_var_2 }}"
arch="${{ steps.build.outputs.host_env_arch }}"
distro="${{ steps.build.outputs.host_env_distro }}"
echo "Assert env_arch: '$arch' == '${{ matrix.arch }}'"
test "$arch" == "${{ matrix.arch }}"
echo "Assert var_1: '$var_1' == 'value_1'"
test "$var_1" == "value_1"
echo "Assert env_distro: '$distro' == '${{ matrix.distro }}'"
test "$distro" == "${{ matrix.distro }}"
- name: Assert install script runs
run: |
git_path="${{ steps.build.outputs.git_path }}"
echo "Assert var_2: '$var_2' == 'value_2'"
test "$var_1" == "value_1"
echo "Assert git path: '$git_path' == '/usr/bin/git'"
test "$git_path" == "/usr/bin/git"
- name: Assert job would fail on setup script error
run: |
Expand Down Expand Up @@ -137,14 +175,14 @@ jobs:
- name: Assert container receives environment variables
run: |
var_1="${{ steps.build.outputs.var_1 }}"
var_2="${{ steps.build.outputs.var_2 }}"
arch="${{ steps.build.outputs.env_arch }}"
distro="${{ steps.build.outputs.env_distro }}"
echo "Assert var_1: '$var_1' == 'value_1'"
test "$var_1" == "value_1"
echo "Assert env_arch: '$arch' == '${{ matrix.arch }}'"
test "$arch" == "${{ matrix.arch }}"
echo "Assert var_2: '$var_2' == 'value_2'"
test "$var_1" == "value_1"
echo "Assert env_distro: '$distro' == '${{ matrix.distro }}'"
test "$distro" == "${{ matrix.distro }}"
- name: Assert job would fail on run script error
run: |
Expand All @@ -159,13 +197,25 @@ jobs:
run: |
volume_1_ls="${{ steps.build.outputs.volume_1_ls }}"
volume_2_ls="${{ steps.build.outputs.volume_2_ls }}"
volume_3_ls="${{ steps.build.outputs.volume_3_ls }}"
volume_4_ls="${{ steps.build.outputs.volume_4_ls }}"
volume_5_ls="${{ steps.build.outputs.volume_5_ls }}"
echo "Assert volume_1_ls: '$volume_1_ls' == 'file_1'"
test "$volume_1_ls" == "file_1"
echo "Assert volume_2_ls: '$volume_2_ls' == 'file_2'"
test "$volume_2_ls" == "file_2"
echo "Assert volume_3_ls: '$volume_3_ls' == 'file_3'"
test "$volume_3_ls" == "file_3"
echo "Assert volume_4_ls: '$volume_4_ls' == 'file_4'"
test "$volume_4_ls" == "file_4"
echo "Assert volume_5_ls: '$volume_5_ls' == 'file_5'"
test "$volume_5_ls" == "file_5"
- name: Assert container determines correct default shell for distro
run: |
shebang="${{ steps.build.outputs.shebang }}"
Expand Down
3 changes: 3 additions & 0 deletions Dockerfiles/Dockerfile.aarch64.alpine_latest
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
FROM arm64v8/alpine:latest

COPY ./run-on-arch-install.sh /root/run-on-arch-install.sh
RUN chmod +x /root/run-on-arch-install.sh && /root/run-on-arch-install.sh
3 changes: 3 additions & 0 deletions Dockerfiles/Dockerfile.aarch64.buster
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
FROM arm64v8/debian:buster

COPY ./run-on-arch-install.sh /root/run-on-arch-install.sh
RUN chmod +x /root/run-on-arch-install.sh && /root/run-on-arch-install.sh
3 changes: 3 additions & 0 deletions Dockerfiles/Dockerfile.aarch64.fedora_latest
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
FROM arm64v8/fedora:latest

COPY ./run-on-arch-install.sh /root/run-on-arch-install.sh
RUN chmod +x /root/run-on-arch-install.sh && /root/run-on-arch-install.sh
3 changes: 3 additions & 0 deletions Dockerfiles/Dockerfile.aarch64.stretch
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
FROM arm64v8/debian:stretch

COPY ./run-on-arch-install.sh /root/run-on-arch-install.sh
RUN chmod +x /root/run-on-arch-install.sh && /root/run-on-arch-install.sh
3 changes: 3 additions & 0 deletions Dockerfiles/Dockerfile.aarch64.ubuntu16.04
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
FROM arm64v8/ubuntu:16.04

COPY ./run-on-arch-install.sh /root/run-on-arch-install.sh
RUN chmod +x /root/run-on-arch-install.sh && /root/run-on-arch-install.sh
2 changes: 2 additions & 0 deletions Dockerfiles/Dockerfile.aarch64.ubuntu18.04
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
FROM arm64v8/ubuntu:18.04

COPY ./run-on-arch-install.sh /root/run-on-arch-install.sh
RUN chmod +x /root/run-on-arch-install.sh && /root/run-on-arch-install.sh
3 changes: 3 additions & 0 deletions Dockerfiles/Dockerfile.aarch64.ubuntu20.04
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
FROM arm64v8/ubuntu:20.04


COPY ./run-on-arch-install.sh /root/run-on-arch-install.sh
RUN chmod +x /root/run-on-arch-install.sh && /root/run-on-arch-install.sh
3 changes: 3 additions & 0 deletions Dockerfiles/Dockerfile.armv6.alpine_latest
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
FROM balenalib/raspberry-pi-alpine:latest

COPY ./run-on-arch-install.sh /root/run-on-arch-install.sh
RUN chmod +x /root/run-on-arch-install.sh && /root/run-on-arch-install.sh
3 changes: 3 additions & 0 deletions Dockerfiles/Dockerfile.armv6.buster
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
FROM balenalib/rpi-raspbian:buster

COPY ./run-on-arch-install.sh /root/run-on-arch-install.sh
RUN chmod +x /root/run-on-arch-install.sh && /root/run-on-arch-install.sh
3 changes: 3 additions & 0 deletions Dockerfiles/Dockerfile.armv6.jessie
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
FROM balenalib/rpi-raspbian:jessie

COPY ./run-on-arch-install.sh /root/run-on-arch-install.sh
RUN chmod +x /root/run-on-arch-install.sh && /root/run-on-arch-install.sh
3 changes: 3 additions & 0 deletions Dockerfiles/Dockerfile.armv6.stretch
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
FROM balenalib/rpi-raspbian:stretch

COPY ./run-on-arch-install.sh /root/run-on-arch-install.sh
RUN chmod +x /root/run-on-arch-install.sh && /root/run-on-arch-install.sh
3 changes: 3 additions & 0 deletions Dockerfiles/Dockerfile.armv7.alpine_latest
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
FROM arm32v7/debian:buster

COPY ./run-on-arch-install.sh /root/run-on-arch-install.sh
RUN chmod +x /root/run-on-arch-install.sh && /root/run-on-arch-install.sh
3 changes: 3 additions & 0 deletions Dockerfiles/Dockerfile.armv7.buster
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
FROM arm32v7/debian:buster

COPY ./run-on-arch-install.sh /root/run-on-arch-install.sh
RUN chmod +x /root/run-on-arch-install.sh && /root/run-on-arch-install.sh
3 changes: 3 additions & 0 deletions Dockerfiles/Dockerfile.armv7.jessie
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
FROM arm32v7/debian:jessie

COPY ./run-on-arch-install.sh /root/run-on-arch-install.sh
RUN chmod +x /root/run-on-arch-install.sh && /root/run-on-arch-install.sh
3 changes: 3 additions & 0 deletions Dockerfiles/Dockerfile.armv7.stretch
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
FROM arm32v7/debian:stretch

COPY ./run-on-arch-install.sh /root/run-on-arch-install.sh
RUN chmod +x /root/run-on-arch-install.sh && /root/run-on-arch-install.sh
3 changes: 3 additions & 0 deletions Dockerfiles/Dockerfile.armv7.ubuntu16.04
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
FROM arm32v7/ubuntu:16.04

COPY ./run-on-arch-install.sh /root/run-on-arch-install.sh
RUN chmod +x /root/run-on-arch-install.sh && /root/run-on-arch-install.sh
3 changes: 3 additions & 0 deletions Dockerfiles/Dockerfile.armv7.ubuntu18.04
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
FROM arm32v7/ubuntu:18.04

COPY ./run-on-arch-install.sh /root/run-on-arch-install.sh
RUN chmod +x /root/run-on-arch-install.sh && /root/run-on-arch-install.sh
3 changes: 3 additions & 0 deletions Dockerfiles/Dockerfile.armv7.ubuntu20.04
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
FROM arm32v7/ubuntu:20.04

COPY ./run-on-arch-install.sh /root/run-on-arch-install.sh
RUN chmod +x /root/run-on-arch-install.sh && /root/run-on-arch-install.sh
3 changes: 3 additions & 0 deletions Dockerfiles/Dockerfile.ppc64le.alpine_latest
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
FROM ppc64le/alpine:latest

COPY ./run-on-arch-install.sh /root/run-on-arch-install.sh
RUN chmod +x /root/run-on-arch-install.sh && /root/run-on-arch-install.sh
3 changes: 3 additions & 0 deletions Dockerfiles/Dockerfile.ppc64le.buster
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
FROM ppc64le/debian:buster

COPY ./run-on-arch-install.sh /root/run-on-arch-install.sh
RUN chmod +x /root/run-on-arch-install.sh && /root/run-on-arch-install.sh
3 changes: 3 additions & 0 deletions Dockerfiles/Dockerfile.ppc64le.fedora_latest
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
FROM ppc64le/fedora:latest

COPY ./run-on-arch-install.sh /root/run-on-arch-install.sh
RUN chmod +x /root/run-on-arch-install.sh && /root/run-on-arch-install.sh
3 changes: 3 additions & 0 deletions Dockerfiles/Dockerfile.ppc64le.jessie
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
FROM ppc64le/debian:jessie

COPY ./run-on-arch-install.sh /root/run-on-arch-install.sh
RUN chmod +x /root/run-on-arch-install.sh && /root/run-on-arch-install.sh
3 changes: 3 additions & 0 deletions Dockerfiles/Dockerfile.ppc64le.stretch
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
FROM ppc64le/debian:stretch

COPY ./run-on-arch-install.sh /root/run-on-arch-install.sh
RUN chmod +x /root/run-on-arch-install.sh && /root/run-on-arch-install.sh
3 changes: 3 additions & 0 deletions Dockerfiles/Dockerfile.ppc64le.ubuntu16.04
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
FROM ppc64le/ubuntu:16.04

COPY ./run-on-arch-install.sh /root/run-on-arch-install.sh
RUN chmod +x /root/run-on-arch-install.sh && /root/run-on-arch-install.sh
3 changes: 3 additions & 0 deletions Dockerfiles/Dockerfile.ppc64le.ubuntu18.04
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
FROM ppc64le/ubuntu:18.04

COPY ./run-on-arch-install.sh /root/run-on-arch-install.sh
RUN chmod +x /root/run-on-arch-install.sh && /root/run-on-arch-install.sh
3 changes: 3 additions & 0 deletions Dockerfiles/Dockerfile.ppc64le.ubuntu20.04
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
FROM ppc64le/ubuntu:20.04

COPY ./run-on-arch-install.sh /root/run-on-arch-install.sh
RUN chmod +x /root/run-on-arch-install.sh && /root/run-on-arch-install.sh
3 changes: 3 additions & 0 deletions Dockerfiles/Dockerfile.s390x.alpine_latest
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
FROM s390x/alpine:latest

COPY ./run-on-arch-install.sh /root/run-on-arch-install.sh
RUN chmod +x /root/run-on-arch-install.sh && /root/run-on-arch-install.sh
3 changes: 3 additions & 0 deletions Dockerfiles/Dockerfile.s390x.buster
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
FROM s390x/debian:buster

COPY ./run-on-arch-install.sh /root/run-on-arch-install.sh
RUN chmod +x /root/run-on-arch-install.sh && /root/run-on-arch-install.sh
Loading

0 comments on commit e89804c

Please sign in to comment.