Skip to content

Commit 36dd895

Browse files
authored
refactor-ci-makefile (#60)
1 parent b5ae9c1 commit 36dd895

File tree

3 files changed

+33
-46
lines changed

3 files changed

+33
-46
lines changed

.github/workflows/CI.yml

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,38 +11,41 @@ on:
1111
paths:
1212
- '**Dockerfile'
1313
- 'docker-bake.hcl'
14+
workflow_dispatch:
1415

1516
jobs:
1617
build:
1718
runs-on: ubuntu-latest
1819
steps:
1920
- uses: actions/checkout@v2
20-
- name: Run pre-commit to check all files
21-
run: |
22-
pip install pre-commit
23-
pre-commit install
24-
pre-commit run --all-files
25-
- name: Login container registry
26-
run: |
27-
echo $CR_PAT | docker login ghcr.io -u shenxianpeng --password-stdin
28-
env:
29-
CR_PAT: ${{ secrets.CR_PAT }}
21+
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v2.8.0
24+
25+
- name: Check formatting
26+
run: make install-deps && make lint
27+
3028
- name: Get changed files
3129
id: changed-files
3230
uses: tj-actions/changed-files@v18.4
33-
- name: Set up Docker Buildx
34-
uses: docker/setup-buildx-action@v2.8.0
35-
- name: Build & Test (Publish) image
31+
32+
- name: Login container registries
3633
run: |
34+
echo $CR_PAT | docker login ghcr.io -u shenxianpeng --password-stdin
3735
docker login -u '${{ secrets.DOCKER_USERNAME }}' -p '${{ secrets.DOCKER_PASSWORD }}'
36+
env:
37+
CR_PAT: ${{ secrets.CR_PAT }}
38+
39+
- name: Build & Test & (Publish) image
40+
run: |
3841
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
3942
if [[ "$file" == *"Dockerfile" ]]; then
4043
set -e
41-
docker buildx bake --file docker-bake.hcl clang-tools-`dirname $file`
42-
docker images
43-
44-
echo "start to test ..."
4544
tag=`dirname $file`
45+
echo "start to build clang-tools:$tag"
46+
docker buildx bake --file docker-bake.hcl clang-tools-$tag
47+
48+
echo "start to test clang-tools:$tag"
4649
if [ $tag == "all" ]; then
4750
clang_versions="16 15 14 13 12 11 10 9 8"
4851
for clang_version in ${clang_versions}; do
@@ -58,8 +61,10 @@ jobs:
5861
fi
5962
6063
if [[ $GITHUB_EVENT_NAME == 'push' ]]; then
61-
echo "start to publish ..."
62-
docker buildx bake --file docker-bake.hcl --push clang-tools-`dirname $file`
64+
echo "start to publish clang-tools:$tag"
65+
docker buildx bake --file docker-bake.hcl --push clang-tools-$tag
6366
fi
67+
else
68+
docker buildx bake --file docker-bake.hcl clang-tools-$tag --print
6469
fi
6570
done

.github/workflows/release-images.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ help: ## Show this Makefile's help
2828

2929
.DEFAULT_GOAL := help
3030

31+
.PHONY: .pre-commit ## Check that pre-commit is installed
32+
.pre-commit:
33+
@pre-commit -V || echo 'Please install pre-commit: https://pre-commit.com/'
34+
3135
# DOCKER TASKS
3236
build: ## Build the Docker Image
3337
@echo "== Building Image ..."
@@ -49,7 +53,11 @@ prune: ## Clean all that is not actively used
4953
@docker system prune -af
5054
@echo "== Prune image(s) succeeded"
5155

52-
lint: ## Lint code
56+
install-deps: ## Install development denpendeces
57+
@pip install -U pre-commit
58+
@pre-commit install
59+
60+
lint: .pre-commit ## Lint code
5361
@echo "== Running pre-commit against all-files..."
5462
@pre-commit run --all-files
5563
@echo "== Lint succeeded"

0 commit comments

Comments
 (0)