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
36 changes: 36 additions & 0 deletions .github/workflows/generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
set -Eeuo pipefail

bashbrewDir="$1"; shift

if [ "$#" -eq 0 ]; then
git fetch --quiet https://github.com/docker-library/official-images.git master
changes="$(git diff --numstat FETCH_HEAD...HEAD -- library/ | cut -d$'\t' -f3-)"
repos="$(xargs -rn1 basename <<<"$changes")"
set -- $repos
fi

strategy='{}'
for repo; do
newStrategy="$(GITHUB_REPOSITORY="$repo" GENERATE_STACKBREW_LIBRARY='cat "library/$GITHUB_REPOSITORY"' "$bashbrewDir/scripts/github-actions/generate.sh")"
newStrategy="$(jq -c --arg repo "$repo" '.matrix.include = [
.matrix.include[]
| ([ .meta.entries[].tags[0] ]) as $tags
| .name = ($tags | join(", "))
| .runs.prepare += "\ngit clone --depth 1 https://github.com/docker-library/bashbrew.git ~/bashbrew\n~/bashbrew/bashbrew.sh --version"
| .runs.build = (
(if .os | startswith("windows-") then "export BASHBREW_ARCH=windows-amd64 BASHBREW_CONSTRAINTS=" + ([ .meta.entries[].constraints[] ] | join(", ") | @sh) + "\n" else "" end)
+ "export BASHBREW_LIBRARY=\"$PWD/library\"\n"
+ ([ $tags[] | "~/bashbrew/bashbrew.sh build " + @sh ] | join("\n"))
)
]' <<<"$newStrategy")"
jq -c . <<<"$newStrategy" > /dev/null # sanity check
strategy="$(jq -c --argjson strategy "$strategy" '.matrix.include = ($strategy.matrix.include // []) + .matrix.include' <<<"$newStrategy")"
done
jq -c . <<<"$strategy" > /dev/null # sanity check

if [ -t 1 ]; then
jq <<<"$strategy"
else
cat <<<"$strategy"
fi
60 changes: 60 additions & 0 deletions .github/workflows/naughty.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env bash
set -Eeuo pipefail

if [ "$#" -eq 0 ]; then
git fetch --quiet https://github.com/docker-library/official-images.git master
changes="$(git diff --numstat FETCH_HEAD...HEAD -- library/ | cut -d$'\t' -f3-)"
repos="$(xargs -rn1 basename <<<"$changes")"
set -- $repos
fi

if [ "$#" -eq 0 ]; then
echo >&2 'No library/ changes detected, skipping.'
exit
fi

export BASHBREW_LIBRARY="$PWD/library"

bashbrew from --uniq "$@" > /dev/null

if badTags="$(bashbrew list "$@" | grep -E ':.+latest.*|:.*latest.+')" && [ -n "$badTags" ]; then
echo >&2
echo >&2 "Incorrectly formatted 'latest' tags detected:"
echo >&2 ' ' $badTags
echo >&2
echo >&2 'Read https://github.com/docker-library/official-images#tags-and-aliases for more details.'
echo >&2
exit 1
fi

naughtyFrom="$(./naughty-from.sh "$@")"
if [ -n "$naughtyFrom" ]; then
echo >&2
echo >&2 "Invalid 'FROM' + 'Architectures' combinations detected:"
echo >&2
echo >&2 "$naughtyFrom"
echo >&2
echo >&2 'Read https://github.com/docker-library/official-images#multiple-architectures for more details.'
echo >&2
exit 1
fi

naughtyConstraints="$(./naughty-constraints.sh "$@")"
if [ -n "$naughtyConstraints" ]; then
echo >&2
echo >&2 "Invalid 'FROM' + 'Constraints' combinations detected:"
echo >&2
echo >&2 "$naughtyConstraints"
echo >&2
exit 1
fi

naughtyCommits="$(./naughty-commits.sh "$@")"
if [ -n "$naughtyCommits" ]; then
echo >&2
echo >&2 "Unpleasant commits detected:"
echo >&2
echo >&2 "$naughtyCommits"
echo >&2
exit 1
fi
22 changes: 22 additions & 0 deletions .github/workflows/pr-labels.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -Eeuo pipefail

git fetch --quiet https://github.com/docker-library/official-images.git master

changes="$(git diff --numstat FETCH_HEAD...HEAD -- library/ | cut -d$'\t' -f3-)"
set -- $changes

if [ "$#" -eq 0 ]; then
echo >&2 'No library/ changes detected, skipping labels.'
exit
fi

if newImages="$(git diff --name-only --diff-filter=A FETCH_HEAD...HEAD -- "$@")" && [ -n "$newImages" ]; then
echo >&2
echo >&2 "NEW IMAGES: $newImages"
echo >&2
set -- "$@" 'new-image'
fi

IFS=$'\n'
echo "$*"
132 changes: 132 additions & 0 deletions .github/workflows/test-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
name: Test PR

on:
pull_request:

defaults:
run:
shell: 'bash -Eeuo pipefail -x {0}'

jobs:

naughty:
name: Naughty
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Check for Common Issues
run: |
git clone --depth 1 https://github.com/docker-library/bashbrew.git -b master ~/bashbrew
~/bashbrew/bashbrew.sh --version > /dev/null
export PATH="$HOME/bashbrew/bin:$PATH"
bashbrew --version
.github/workflows/naughty.sh

label:
name: Label
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- id: labels
name: Generate List
run: |
labels="$(.github/workflows/pr-labels.sh)"
labels="$(jq -Rsc 'rtrimstr("\n") | split("\n") | { labels: ., count: length }' <<<"$labels")"
jq . <<<"$labels"
echo "::set-output name=labels::$labels"
- name: Apply Labels
uses: actions/[email protected]
with:
script: |
const data = ${{ steps.labels.outputs.labels }}
github.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
labels: data.labels,
})
if: fromJSON(steps.labels.outputs.labels).count > 0

diff:
name: Diff
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- id: diff
name: Run ./diff-pr.sh
run: |
git clone --depth 1 https://github.com/docker-library/bashbrew.git -b master ~/bashbrew
~/bashbrew/bashbrew.sh --version > /dev/null
export PATH="$HOME/bashbrew/bin:$PATH"
bashbrew --version
diff="$(./diff-pr.sh 0)"
# "Body is too long (maximum is 65536 characters)" (so we'll check for some fudge room and pre-filter the diff)
# TODO consider instead creating a Gist (although that requires a separate type of token, so much less interesting)
diff="$(jq -Rcs 'rtrimstr("\n") | { diff: (if length < 65000 then . else "TODO diff too large for GitHub comment!\nSee: https://github.com/" + env.GITHUB_REPOSITORY + "/actions/runs/" + env.GITHUB_RUN_ID end), length: length }' <<<"$diff")"
echo "::set-output name=diff::$diff"
- name: Delete Old Comments
uses: actions/[email protected]
with:
script: |
const { data: comments } = await github.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
})
comments.forEach((comment) => {
if (comment.user.login === 'github-actions[bot]') {
github.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: comment.id,
})
}
})
- name: Create Diff Comment
uses: actions/[email protected]
with:
script: |
const data = ${{ steps.diff.outputs.diff }}
const body = "<details>\n<summary>Diff for " + context.payload.pull_request.head.sha + ":</summary>\n\n```diff\n" + data.diff + "\n```\n\n</details>"
github.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: body,
})
if: fromJSON(steps.diff.outputs.diff).length > 0

generate-jobs:
name: Generate Jobs
runs-on: ubuntu-latest
outputs:
strategy: ${{ steps.generate-jobs.outputs.strategy }}
steps:
- uses: actions/checkout@v2
- id: generate-jobs
name: Generate Jobs
run: |
git clone --depth 1 https://github.com/docker-library/bashbrew.git -b master ~/bashbrew
strategy="$(.github/workflows/generate.sh ~/bashbrew)"
jq . <<<"$strategy" # sanity check / debugging aid
echo "::set-output name=strategy::$strategy"

test:
needs: generate-jobs
strategy: ${{ fromJson(needs.generate-jobs.outputs.strategy) }}
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Prepare Environment
run: ${{ matrix.runs.prepare }}
- name: Pull Dependencies
run: ${{ matrix.runs.pull }}
- name: Build ${{ matrix.name }}
run: ${{ matrix.runs.build }}
- name: History ${{ matrix.name }}
run: ${{ matrix.runs.history }}
- name: Test ${{ matrix.name }}
run: ${{ matrix.runs.test }}
- name: '"docker images"'
run: ${{ matrix.runs.images }}
101 changes: 0 additions & 101 deletions .travis.sh

This file was deleted.

15 changes: 0 additions & 15 deletions .travis.yml

This file was deleted.

2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Docker Official Images

[![Build Status](https://travis-ci.org/docker-library/official-images.svg?branch=master)](https://travis-ci.org/docker-library/official-images)

## Table of Contents

<!-- AUTOGENERATED TOC -->
Expand Down
Loading