Skip to content

Commit

Permalink
chore: general updates and housekeeping
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsimonemms committed May 2, 2024
1 parent 770b055 commit 1259e36
Show file tree
Hide file tree
Showing 12 changed files with 129 additions and 156 deletions.
3 changes: 0 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,5 @@
}
}
},
"postCreateCommand": {
"cookieninja-cruft": "pip install cruft"
},
"updateContentCommand": "npm install -g @devcontainers/cli"
}
20 changes: 0 additions & 20 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

# editorconfig.org
root = true

Expand All @@ -30,9 +13,6 @@ insert_final_newline = true
indent_style = tab
indent_size = 4

[*.md]
trim_trailing_whitespace = false

[Makefile]
indent_style = tab
indent_size = 4
134 changes: 92 additions & 42 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

name: Build
on:
push:
branches:
- "*"
- main
tags:
- "v*.*.*"
pull_request:
branches:
- main
Expand All @@ -29,40 +14,79 @@ on:
permissions:
contents: write
packages: write
pull-requests: read
jobs:
features:
if: ${{ github.ref == 'refs/heads/main' }}
commitlint:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: '{{ "${{ secrets.GITHUB_TOKEN }}" }}'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # fetch-depth is required

- uses: wagoid/commitlint-github-action@v5

pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0 # fetch-depth is required

- name: Publish
uses: devcontainers/action@v1
- name: Set up Go without go.mod
uses: actions/setup-go@v5
if: ${{ hashFiles('go.mod') == '' }}
with:
publish-features: "true"
base-path-to-features: "./features"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
check-latest: true

- name: Set up Go with go.mod
uses: actions/setup-go@v5
if: ${{ hashFiles('go.mod') != '' }}
with:
go-version-file: go.mod

- uses: actions/setup-python@v5
with:
python-version: 3.x

- name: Setup JS
uses: actions/setup-node@v4
with:
node-version: lts/*

- name: Install dependencies
run: |
go install ./... || true
npm ci || true
- uses: pre-commit/[email protected]

base:
runs-on: ubuntu-latest
needs:
- commitlint
- pre-commit
outputs:
docker_registry: ${{ steps.tags.outputs.docker_registry }}
matrix: ${{ steps.tags.outputs.matrix }}
tag: ${{ steps.tags.outputs.tag }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup JS
uses: actions/setup-node@v4
with:
fetch-depth: 0
node-version: lts/*

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
Expand All @@ -72,7 +96,7 @@ jobs:
id: tags
run: |
echo "docker_registry=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT"
echo "matrix={\"img\": $(jq -ncR '[inputs]' <<< $(ls -d images/*))}" >> "$GITHUB_OUTPUT"
echo "matrix={\"img\": $(jq -ncR '[inputs]' <<< $(ls -d images/* | grep -v '/base'))}" >> "$GITHUB_OUTPUT"
echo "tag=$(date --iso-8601)" >> "$GITHUB_OUTPUT"
- name: Install Dev Container CLI
Expand All @@ -88,39 +112,51 @@ jobs:
--platform=linux/amd64 \
--image-name=${{ steps.tags.outputs.docker_registry }}/base:${{ steps.tags.outputs.tag }} \
--image-name=${{ steps.tags.outputs.docker_registry }}/base:latest \
--workspace-folder=base
--workspace-folder=images/base
if [ ${{ github.ref == 'refs/heads/main' }} = "true" ]; then
echo "Pushing images"
docker push ${{ steps.tags.outputs.docker_registry }}/base:${{ steps.tags.outputs.tag }}
docker push ${{ steps.tags.outputs.docker_registry }}/base:latest
else
echo "Saving base image"
docker save ${{ steps.tags.outputs.docker_registry }}/base:latest -o base.tar.gz
fi
- name: Archive Docker image
uses: actions/upload-artifact@v4
if: ${{ github.ref != 'refs/heads/main' }}
with:
name: docker-image
path: base.tar.gz
if-no-files-found: error
retention-days: 1
compression-level: 0
overwrite: true

images:
runs-on: ubuntu-latest
needs:
- base
strategy:
matrix: ${{ fromJSON(needs.base.outputs.matrix) }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/checkout@v4

- name: Set up Node
uses: actions/setup-node@v3
- name: Setup JS
uses: actions/setup-node@v4
with:
node-version: lts/*

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
Expand All @@ -136,8 +172,22 @@ jobs:
npm install -g @devcontainers/cli
devcontainer --version
- name: Import Docker image
uses: actions/download-artifact@v4
if: ${{ github.ref != 'refs/heads/main' }}
with:
name: docker-image

- name: Build Dev Container
run: |
if [ ${{ github.ref == 'refs/heads/main' }} = "true" ]; then
echo "Pulling image from registry"
docker pull ${{ needs.base.outputs.docker_registry }}/base
else
echo "Importing image from cache"
docker import base.tar.gz ${{ needs.base.outputs.docker_registry }}/base
fi
docker pull ${{ needs.base.outputs.docker_registry }}/${{ steps.tags.outputs.name }}:latest || true
devcontainer build \
Expand Down
30 changes: 0 additions & 30 deletions .github/workflows/commitlint.yml

This file was deleted.

17 changes: 0 additions & 17 deletions .github/workflows/update-documentation.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

name: "Update Documentation"
on:
push:
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@ node_modules
.DS_Store
Thumbs.db
.commit
.devbox
.envrc
output
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"editor.formatOnSave": true,
"editor.rulers": [
80
],
"yaml.schemas": {
"https://json.schemastore.org/github-workflow.json": [
".github/workflows/*.{yml,yaml}"
Expand Down
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ representative at an online or offline event.

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
[email protected].
[[email protected]].
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
Expand Down
18 changes: 4 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ DOCKER_REPO ?= ghcr.io/mrsimonemms/devcontainers
IMG_DIR = images
PLATFORM ?= linux/amd64

all: build-all

build-all:
@$(MAKE) install-devcontainers

@if ! command devcontainer --version; then \
npm i -g @devcontainers/cli; \
fi

@$(MAKE) build-base build-images
.PHONY: build-all

Expand All @@ -34,11 +32,11 @@ build:
.PHONY: build

build-base:
$(MAKE) build IMG_NAME="base" CONTEXT="base"
$(MAKE) build IMG_NAME="base" CONTEXT="${IMG_DIR}/base"
.PHONY: build-base

build-images:
@for img_path in $(shell ls -d ${IMG_DIR}/*); do \
@for img_path in $(shell ls -d ${IMG_DIR}/* | grep -v '/base'); do \
name=$$(echo $${img_path} | sed "s/${IMG_DIR}\///"); \
\
$(MAKE) build IMG_NAME="$${name}" CONTEXT="$${img_path}"; \
Expand All @@ -51,11 +49,3 @@ install-devcontainers:
npm i -g @devcontainers/cli; \
fi
.PHONY: install-devcontainers

cruft-update:
ifeq (,$(wildcard .cruft.json))
@echo "Cruft not configured"
else
@cruft check || cruft update --skip-apply-ask --refresh-private-variables
endif
.PHONY: cruft-update
Loading

0 comments on commit 1259e36

Please sign in to comment.