-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ci): Simplify CI and introduce devbox ( fixes: #32 )
This commit simplifies the CI by removing the Docker-based build and test process. Instead, it introduces devbox, a tool that provides a consistent development environment across different machines. The CI now uses actions/checkout@v4 and devbox for setting up the environment. The build and test commands are run using devbox. The Dockerfile has been removed as it's no longer needed. The devbox configuration is provided in devbox.json and devbox.lock. The deployment to GitHub Pages has been commented out for now.
- Loading branch information
Showing
4 changed files
with
465 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,99 +12,33 @@ jobs: | |
fmt: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: goto-bus-stop/setup-zig@v1 | ||
- uses: actions/checkout@v4 | ||
with: | ||
version: 0.10.1 | ||
- run: zig fmt --check *.zig src/**/*.zig | ||
submodules: recursive | ||
- name: Install devbox | ||
uses: jetify-com/[email protected] | ||
- run: devbox run fmt-check | ||
|
||
build_docker_image: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- uses: actions/checkout@v4 | ||
with: | ||
driver-opts: | | ||
image=moby/buildkit:v0.10.6 | ||
- name: create tag | ||
run: | | ||
IMAGE="ghcr.io/${{ github.repository }}" | ||
SHA=${{ github.sha }} | ||
IMAGE_LATEST="$IMAGE:latest" | ||
IMAGE_SHA="$IMAGE:$SHA" | ||
if [ "${{ github.ref }}" == "refs/heads/main" ]; then | ||
TAGS="$IMAGE_SHA,$IMAGE_LATEST" | ||
else | ||
TAGS=$IMAGE_SHA | ||
fi | ||
echo "IMAGE=$IMAGE" >> $GITHUB_ENV | ||
echo "IMAGE_LATEST=$IMAGE_LATEST" >> $GITHUB_ENV | ||
echo "IMAGE_SHA=$IMAGE_SHA" >> $GITHUB_ENV | ||
echo "TAGS=$TAGS" >> $GITHUB_ENV | ||
- name: get current date | ||
id: date | ||
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV | ||
- name: Login GitHub Packages | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build and push docker image & save chache | ||
uses: docker/build-push-action@v3 | ||
with: | ||
push: true | ||
tags: ${{ env.TAGS }} | ||
build-args: | | ||
CACHE_DATE=${{ env.CURRENT_DATE }} | ||
cache-from: type=registry,ref=${{ env.IMAGE }}:buildcache | ||
cache-to: type=registry,ref=${{ env.IMAGE }}:buildcache,mode=max | ||
|
||
run_test_and_build_docs: | ||
runs-on: ubuntu-latest | ||
needs: build_docker_image | ||
container: | ||
image: ghcr.io/${{ github.repository }}:${{ github.sha }} | ||
credentials: | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.github_token }} | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: true | ||
- run: git config --global --add safe.directory /__w/zigcv/zigcv | ||
shell: bash | ||
- run: zig version | ||
- name: save zig-cache | ||
id: docker_cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: ./zig-cache | ||
key: ${{ runner.os }}-zig-cache-${{ github.event.repository.updated_at }} | ||
restore-keys: | | ||
${{ runner.os }}-zig-cache- | ||
- name: test and build docs | ||
run: zig build test -Ddocs=${{ github.ref == 'refs/heads/main' }} | ||
- name: build examples | ||
run: zig build examples | ||
- uses: actions/upload-pages-artifact@v1 | ||
if: github.ref == 'refs/heads/main' | ||
with: | ||
path: docs | ||
submodules: recursive | ||
- name: Install devbox | ||
uses: jetify-com/[email protected] | ||
- run: devbox run test | ||
|
||
deploy: | ||
needs: run_test_and_build_docs | ||
permissions: | ||
pages: write | ||
id-token: write | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
runs-on: ubuntu-latest | ||
if: github.ref == 'refs/heads/main' | ||
steps: | ||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v1 | ||
# deploy: | ||
# permissions: | ||
# pages: write | ||
# id-token: write | ||
# environment: | ||
# name: github-pages | ||
# url: ${{ steps.deployment.outputs.page_url }} | ||
# runs-on: ubuntu-latest | ||
# if: github.ref == 'refs/heads/main' | ||
# steps: | ||
# - name: Deploy to GitHub Pages | ||
# id: deployment | ||
# uses: actions/deploy-pages@v1 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.10.6/.schema/devbox.schema.json", | ||
"packages": [ | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected]", | ||
"pkg-config@latest", | ||
"curl@latest", | ||
"unzip@latest" | ||
], | ||
"shell": { | ||
"scripts": { | ||
"version": "zig version", | ||
"build": "zig build --verbose", | ||
"test": "zig build test --verbose", | ||
"fmt": "zig fmt ./**/*.zig", | ||
"fmt-check": "zig fmt --check ./**/*.zig" | ||
} | ||
} | ||
} |
Oops, something went wrong.