Skip to content

Commit

Permalink
first version
Browse files Browse the repository at this point in the history
  • Loading branch information
idodod committed Mar 25, 2024
1 parent bf01fb0 commit cd5aff2
Show file tree
Hide file tree
Showing 13 changed files with 931 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .arg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DOCKERHUB_USER=earthly
IMAGE_NAME=dind
EARTHLY_REPO_VERSION=ido-dind-preparations
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# PRs require approval from the earthly core team
* @earthly/core
102 changes: 102 additions & 0 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
$schema: "https://docs.renovatebot.com/renovate-schema.json",
extends: [
"config:recommended"
],
configMigration: true,
prHourlyLimit: 1,
schedule: [ // utc timezone
'after 6am on monday',
],
enabledManagers: [
'dockerfile',
'custom.regex',
'github-actions',
],
dockerfile: {
fileMatch: [
'Earthfile',
],
},
customManagers: [
{
// Earthly Version in GH Actions
customType: 'regex',
fileMatch: [
'.*?\\.yml',
],
matchStrings: [
'- uses: earthly/actions/setup-earthly@.*?[\\s\\n]+.*?[\\s\\n]+with:[\\s\\n]*version: (?<currentValue>.*?)[\\s\\n/]+',
],
depNameTemplate: 'earthly/earthly',
datasourceTemplate: 'github-releases',
},
{
// ARG/LET in Earthfile that have a Renovate comment
customType: 'regex',
fileMatch: [
'Earthfile',
],
matchStrings: [
'\\s*#\\s*renovate:\\s*datasource=(?<datasource>.*?)\\s+depName=(?<depName>.*?)[\\s\\n]+(versioning=(?<versioning>.*?)\\s+)?(ARG|LET)\\s+.*?(_VERSION|_VER|version)=(?<currentValue>.*?)($|\\s|\\n)',
],
},
{
// Updating the Repology alpine version
customType: 'regex',
fileMatch: [
'Earthfile',
],
matchStrings: [
'# renovate: datasource=repology depName=alpine_(?<currentValue>\\d+_\\d+)',
],
currentValueTemplate: "{{{ replace '_' '.' currentValue }}}",
datasourceTemplate: 'docker',
depNameTemplate: 'alpine',
versioningTemplate: 'regex:^(?<major>\\d+)[._](?<minor>\\d+)$',
autoReplaceStringTemplate: '# renovate: datasource=repology depName=alpine_{{{newMajor}}}_{{{newMinor}}}',
},
{
// Updating the commit hash of earthly/earthly
customType: 'regex',
fileMatch: ['^\\.arg$'],
matchStrings: [
'EARTHLY_REPO_VERSION=(?<currentDigest>.*?)($|\\s|\\n)',
],
currentValueTemplate: 'main',
depNameTemplate: 'earthly/earthly',
packageNameTemplate: 'https://github.com/earthly/earthly',
datasourceTemplate: 'git-refs',
},
],
labels: [
'renovate',
],
packageRules: [
// set the group name for alpine dind dependencies
{
groupName: "{{{ replace 'os\\/(.*?)$' '$1' packageFileDir}}}-dind-image",
matchPackagePatterns: [
'alpine',
'alpine.*?/docker',
'docker/docker',
],
matchManagers: [
'custom.regex',
],
matchDatasources: [
'docker',
'repology',
'github-releases',
],
matchFileNames: [
'os/**/Earthfile',
],
},
{
// let all package updates auto merge
matchPackagePatterns: [ '*' ],
automerge: true,
},
],
}
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CI

on:
# TODO: enable when this bug is resolved: https://github.com/earthly/earthly/issues/3930
# push:
# branches: [ "main" ]
pull_request:
branches: [ "main" ]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
test:
name: test
runs-on: ubuntu-latest
env:
FORCE_COLOR: 1
EARTHLY_CONVERSION_PARALLELISM: "5"
EARTHLY_TOKEN: "${{ secrets.EARTHLY_TOKEN }}"
EARTHLY_INSTALL_ID: "earthly-dind-githubactions"
steps:
- uses: earthly/actions/setup-earthly@v1
with:
version: v0.8.5
- uses: actions/checkout@v4
- name: Docker login (non fork only)
run: |-
docker login --username "${{ secrets.DOCKERHUB_USERNAME }}" --password "${{ secrets.DOCKERHUB_TOKEN }}"
docker login registry-1.docker.io.mirror.corp.earthly.dev --username "${{ secrets.DOCKERHUB_MIRROR_USERNAME }}" --password "${{ secrets.DOCKERHUB_MIRROR_PASSWORD }}"
if: github.event.pull_request.head.repo.full_name == github.repository
- name: Configure Earthly to use mirror (non fork only)
run: |-
earthly config global.buildkit_additional_config "'[registry.\"docker.io\"]
mirrors = [\"registry-1.docker.io.mirror.corp.earthly.dev\"]'"
if: github.event.pull_request.head.repo.full_name == github.repository
- name: Run tests
run: |-
earthly config git "{github.com: {auth: ssh, user: git}}" && \
eval $(ssh-agent) && \
earthly secrets --org earthly-technologies --project core get littleredcorvette-id_rsa | ssh-add - && \
earthly --ci -P --push --org earthly-technologies --satellite dind +test
37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Release

on:
pull_request_target:
types: [ closed ]

jobs:
release:
name: release after merging ${{ github.head_ref }}
if: github.event.pull_request.merged == true && startsWith(github.head_ref, 'renovate/') && endsWith(github.head_ref, '-dind-image')
runs-on: ubuntu-latest
env:
FORCE_COLOR: 1
EARTHLY_CONVERSION_PARALLELISM: "5"
EARTHLY_TOKEN: "${{ secrets.EARTHLY_TOKEN }}"
EARTHLY_INSTALL_ID: "earthly-dind-githubactions"
steps:
- uses: earthly/actions/setup-earthly@v1
with:
version: v0.8.5
- uses: actions/checkout@v4
- name: Docker login (non fork only)
run: |-
docker login --username "${{ secrets.DOCKERHUB_USERNAME }}" --password "${{ secrets.DOCKERHUB_TOKEN }}"
docker login registry-1.docker.io.mirror.corp.earthly.dev --username "${{ secrets.DOCKERHUB_MIRROR_USERNAME }}" --password "${{ secrets.DOCKERHUB_MIRROR_PASSWORD }}"
if: github.event.pull_request.head.repo.full_name == github.repository
- name: Configure Earthly to use mirror (non fork only)
run: |-
earthly config global.buildkit_additional_config "'[registry.\"docker.io\"]
mirrors = [\"registry-1.docker.io.mirror.corp.earthly.dev\"]'"
if: github.event.pull_request.head.repo.full_name == github.repository
- name: Build & Push image
run: |-
earthly config git "{github.com: {auth: ssh, user: git}}" && \
eval $(ssh-agent) && \
earthly secrets --org earthly-technologies --project core get littleredcorvette-id_rsa | ssh-add - && \
earthly --ci -P --push --org earthly-technologies --satellite dind +release --RENOVATE_BRANCH=${{github.head_ref}}
15 changes: 15 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Contributing

## Code of Conduct

Please refer to the [CNCF Community Code of Conduct v1.0](https://github.com/cncf/foundation/blob/main/code-of-conduct.md)

## CLA

### Individual

All contributions must indicate agreement to the [Earthly Contributor License Agreement](https://gist.github.com/vladaionescu/ed990fa149a38a53ac74b64155bc6766) by logging into GitHub via the CLA assistant and signing the provided CLA. The CLA assistant will automatically notify the PRs that require CLA signing.

### Entity

If you are an entity, please use the [Earthly Contributor License Agreement form](https://earthly.dev/cla-form) in addition to requiring your individual contributors to sign all contributions.
18 changes: 18 additions & 0 deletions Earthfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
VERSION --wildcard-builds 0.8

PROJECT earthly-technologies/core

# test runs tests for all defined dind images in this repo
test:
BUILD --pass-args ./os/*+test-build

# release expects to get a renovate branch in the form of renovate/<os>-dind-image, extracts the os and then kicks off its +release target
# this is meant to be run by a github workflow
release:
FROM alpine
# RENOVATE_BRANCH is the renovate branch that is expected to get merged and trigger this target
ARG --required RENOVATE_BRANCH
LET os=${RENOVATE_BRANCH#renovate/}
# using a LET/SET in the target path does not work, use an ARG instead until it's fixed
ARG OS=${os%-dind-image}
BUILD --pass-args ./os/$OS+release
Loading

0 comments on commit cd5aff2

Please sign in to comment.