Skip to content

Commit

Permalink
Migrating codebase from PoC repository.
Browse files Browse the repository at this point in the history
Migrating already existing codebase to this new repository.
  • Loading branch information
ricardomaraschini committed Feb 8, 2022
1 parent 6ab33e8 commit 7cdaade
Show file tree
Hide file tree
Showing 5,156 changed files with 1,306,456 additions and 2 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
70 changes: 70 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
name: main

on:
push:
branches:
- main

jobs:
image:
name: image
runs-on: ubuntu-latest
steps:
- name: check out code
uses: actions/checkout@v2

- name: registry login
uses: docker/login-action@v1
with:
registry: ghcr.io
username: shipwright-io
password: ${{ secrets.GITHUB_TOKEN }}

- name: build image and push
uses: docker/build-push-action@v2
with:
push: true
context: ./
file: ./Containerfile
tags: ghcr.io/shipwright-io/imgctrl:latest

release:
name: release
needs:
- image
runs-on: ubuntu-latest
container:
image: quay.io/tagger/actions-image:latest
steps:
- name: checkout source code
uses: actions/checkout@v2

- name: build linux plugin
run: make kubectl-image

- name: compress linux plugin
run: tar -C output/bin -czvf kubectl-image-linux-amd64.tgz kubectl-image

- name: build darwin plugin
run: make kubectl-image-darwin

- name: compress darwin plugin
run: tar -C output/bin -czvf kubectl-image-darwin-amd64.tgz kubectl-image

- name: build helm chart release
run: helm package chart/

- name: build readme pdf
run: make pdf

- name: publish release
uses: marvinpinto/action-automatic-releases@latest
with:
automatic_release_tag: latest
repo_token: ${{ secrets.GITHUB_TOKEN }}
prerelease: true
title: development release build
files: |
*.tgz
output/doc/README.pdf
164 changes: 164 additions & 0 deletions .github/workflows/pullrequest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
# for pull request the actions context is a little bit different. we always use the workflow as
# defined in the main branch, therefore any change in .github/workflow directory introduced by
# the PR is ignored. this happens because if leverage the "on: pull_request_target" instead of
# "on: pull_request". the only practical difference here is that when we checkout the source
# code we use the source repository (the repo used to open the pr), see "check out code" steps.
---
name: pullrequest

on:
pull_request_target:
branches:
- main

jobs:
lint:
name: lint
runs-on: ubuntu-latest
container:
image: quay.io/tagger/actions-image:latest
steps:
- name: check out code
uses: actions/checkout@v2
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}

- name: run linter
run: golint -set_exit_status ./cmd/kubectl-image ./cmd/imgctrl ./controllers/... ./services/...

unit:
name: unit
runs-on: ubuntu-latest
container:
image: quay.io/tagger/actions-image:latest
steps:
- name: check out source code
uses: actions/checkout@v2
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}

- name: run tests
run: go test -mod vendor -v ./...

build:
name: build
needs:
- lint
- unit
runs-on: ubuntu-latest
container:
image: quay.io/tagger/actions-image:latest
steps:
- name: check out code
uses: actions/checkout@v2
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}

- name: build all
run: make build

image:
name: image
needs:
- lint
- unit
runs-on: ubuntu-latest
steps:
- name: check out code
uses: actions/checkout@v2
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}

- name: registry login
uses: docker/login-action@v1
with:
registry: ghcr.io
username: shipwright-io
password: ${{ secrets.GITHUB_TOKEN }}

- name: build image
id: push
uses: docker/build-push-action@v2
with:
push: true
context: ./
file: ./Containerfile
tags: ghcr.io/shipwright-io/imgctrl:pr-${{ github.event.number }}

release:
name: release
needs:
- image
- build
runs-on: ubuntu-latest
steps:
- name: check out code
uses: actions/checkout@v2
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}

- name: setting image tag in values.yaml
run: sed -i 's/latest/pr-${{ github.event.number }}/g' chart/values.yaml

- name: upload helm chart artifact
uses: actions/upload-artifact@v2
with:
name: helm-chart
path: chart

integration:
name: integration
needs:
- release
runs-on: ubuntu-latest
steps:
- name: check out code
uses: actions/checkout@v2
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}

- name: download helm chart artifact
uses: actions/download-artifact@v2
with:
name: helm-chart
path: downloaded-chart

- name: install kuttl
run: |-
curl -o kuttl -L https://github.com/kudobuilder/kuttl/releases/download/v0.11.1/kubectl-kuttl_0.11.1_linux_x86_64
chmod 755 kuttl
- name: install kind
uses: engineerd/[email protected]
with:
version: v0.11.1

- name: create imgctrl namespace
run: |-
kubectl create namespace imgctrl
kubectl config set-context --current --namespace=imctrl
- name: install helm chart
run: helm install imgctrl ./downloaded-chart

- name: sleep for a while
run: sleep 30

- name: check deployments
run: |-
READY=$(kubectl get deploy imgctrl --no-headers -o=custom-columns=:.status.readyReplicas)
if [ "$READY" != "1" ]; then
echo imgctrl deployment not ready
kubectl get deploy -o yaml
kubectl get pods -o yaml
exit 1
fi
- name: e2e
run: ./kuttl test --timeout=180 e2e
84 changes: 84 additions & 0 deletions .github/workflows/tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
name: tag

on:
push:
tags:
- "v*"

jobs:
image:
name: image
runs-on: ubuntu-latest
steps:
- name: check out code
uses: actions/checkout@v2

- name: registry login
uses: docker/login-action@v1
with:
registry: ghcr.io
username: shipwright-io
password: ${{ secrets.GITHUB_TOKEN }}

- name: extract current tag
id: get_tag
run: echo ::set-output name=tag::$(echo $GITHUB_REF | cut -d / -f 3)

- name: build image and push
uses: docker/build-push-action@v2
with:
push: true
build-args:
version=${{ steps.get_tag.outputs.tag }}
context: ./
file: ./Containerfile
tags: ghcr.io/shipwright-io/imgctrl:${{ steps.get_tag.outputs.tag }}

release:
name: release
needs:
- image
runs-on: ubuntu-latest
container:
image: quay.io/tagger/actions-image:latest
steps:
- name: checkout source code
uses: actions/checkout@v2

- name: extract current tag
id: get_tag
run: echo ::set-output name=tag::$(echo $GITHUB_REF | cut -d / -f 3)

- name: build linux plugin
run: VERSION=${{ steps.get_tag.outputs.tag }} make kubectl-image

- name: compress linux plugin
run: tar -C output/bin -czvf kubectl-image-linux-amd64.tgz kubectl-image

- name: build darwin plugin
run: VERSION=${{ steps.get_tag.outputs.tag }} make kubectl-image-darwin

- name: compress darwin plugin
run: tar -C output/bin -czvf kubectl-image-darwin-amd64.tgz kubectl-image

- name: setting image tag in values.yaml
run: sed -i 's/latest/${{ steps.get_tag.outputs.tag }}/g' chart/values.yaml

- name: setting version in chart.yaml
run: sed -i 's/v0.0.0/${{ steps.get_tag.outputs.tag }}/g' chart/Chart.yaml

- name: build helm chart release
run: helm package chart/

- name: build readme pdf
run: make pdf

- name: publish release
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
prerelease: false
files: |
*.tgz
output/doc/README.pdf
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
output
kubeconfig
29 changes: 29 additions & 0 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#
# Builder
#

FROM docker.io/fedora:34 AS builder
RUN dnf install -y \
btrfs-progs-devel \
device-mapper-devel \
gpgme-devel \
go \
make
WORKDIR /src
ARG version
ENV VERSION=${version:-v0.0.0}
COPY . .
RUN make imgctrl
RUN make kubectl-image

#
# Application
#
FROM docker.io/fedora:34
RUN dnf install -y device-mapper-libs
COPY --from=builder /src/output/bin/imgctrl /usr/local/bin/imgctrl
COPY --from=builder /src/output/bin/kubectl-image /usr/local/bin/kubectl-image
# 8080 mutating webhook handlers.
# 8083 images export/import handler.
# 8090 metrics endpoint.
EXPOSE 8080 8083 8090
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
Expand Down
Loading

0 comments on commit 7cdaade

Please sign in to comment.