Skip to content

Commit

Permalink
ci/build: rework the usage of docker container
Browse files Browse the repository at this point in the history
  • Loading branch information
paradajz committed Nov 28, 2024
1 parent b5a290c commit 644cd63
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 145 deletions.
1 change: 1 addition & 0 deletions .devcontainer/Dockerfile.ghcr
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM ghcr.io/shanteacontrols/opendeck:latest
28 changes: 23 additions & 5 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
{
"name": "Existing Docker Compose (Extend)",
"dockerComposeFile": [
"../docker-compose.yml",
"name": "${localWorkspaceFolderBasename}",
"build": {
"dockerfile": "Dockerfile.ghcr",
"context": "${localWorkspaceFolder}"
},
"workspaceMount": "src=${localWorkspaceFolder},dst=/home/ubuntu/project,type=bind",
"workspaceFolder": "/home/ubuntu/project",
"mounts": [
{
"source": "${localEnv:HOME}/.gitconfig",
"target": "/etc/gitconfig",
"type": "bind"
},
{
"source": "${localEnv:HOME}/.ssh",
"target": "/home/ubuntu/.ssh",
"type": "bind"
}
],
"runArgs": [
"--network=host",
"--hostname=${localWorkspaceFolderBasename}"
],
"service": "opendeck",
"workspaceFolder": "/home/ubuntu/workspace/OpenDeck",
"containerUser": "ubuntu",
"customizations": {
"vscode": {
"extensions": [
Expand Down
133 changes: 86 additions & 47 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,74 +2,113 @@ name: CI

on: [push]

defaults:
run:
shell: bash -leo pipefail {0}

env:
CCACHE_DIR: /__w/OpenDeck/OpenDeck/ccache

jobs:
build_and_test_ubuntu:
name: Build/Test [Ubuntu]
runs-on: ubuntu-22.04
container:
image: ghcr.io/shanteacontrols/opendeck:latest
options: --user root
build:
name: Build/Test
runs-on: ubuntu-latest
steps:
- name: Mark repository as safe
run: git config --global --add safe.directory /__w/OpenDeck/OpenDeck
- name: Pull the repository and submodules
- name: Pull the repository
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Restore ccache
uses: actions/cache/restore@v4
with:
path: |
ccache
key: ccache-key
- name: Build and test targets
path: ccache
key: ccache-
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup missing directories and files on the runner
run: |
git fetch --tags
./scripts/build_targets.sh --type=build
./scripts/build_targets.sh --type=test
mkdir -p ~/.ssh
touch ~/.gitconfig
- name: Prepare container
uses: devcontainers/[email protected]
with:
imageName: opendeck # Local name only
imageTag: latest # Local tag only
push: never
- name: Build and test targets
uses: devcontainers/[email protected]
with:
imageName: opendeck
imageTag: latest
push: never
runCmd: |
git fetch --tags
./scripts/build_targets.sh --type=build
./scripts/build_targets.sh --type=test
- name: Save ccache
uses: actions/cache/save@v4
if: always()
with:
path: |
ccache
key: ccache-key
path: ccache
key: "ccache-${{ github.run_id }}"
format:
name: Code formatting
runs-on: ubuntu-22.04
container:
image: ghcr.io/shanteacontrols/opendeck:latest
options: --user root
runs-on: ubuntu-latest
steps:
- name: Mark repository as safe
run: git config --global --add safe.directory /__w/OpenDeck/OpenDeck
- uses: actions/checkout@v4
- name: Pull the repository
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Check formatting
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup missing directories and files on the runner
run: |
make format
mkdir -p ~/.ssh
touch ~/.gitconfig
- name: Prepare container
uses: devcontainers/[email protected]
with:
imageName: opendeck # Local name only
imageTag: latest # Local tag only
push: never
- name: Check formatting
uses: devcontainers/[email protected]
with:
imageName: opendeck
imageTag: latest
push: never
runCmd: |
make format
lint:
name: Code linting
runs-on: ubuntu-22.04
container:
image: ghcr.io/shanteacontrols/opendeck:latest
options: --user root
runs-on: ubuntu-latest
steps:
- name: Mark repository as safe
run: git config --global --add safe.directory /__w/OpenDeck/OpenDeck
- uses: actions/checkout@v4
- name: Pull the repository
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Lint
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup missing directories and files on the runner
run: |
./scripts/build_targets.sh --type=lint
mkdir -p ~/.ssh
touch ~/.gitconfig
- name: Prepare container
uses: devcontainers/[email protected]
with:
imageName: opendeck # Local name only
imageTag: latest # Local tag only
push: never
- name: Check formatting
uses: devcontainers/[email protected]
with:
imageName: opendeck
imageTag: latest
push: never
runCmd: |
./scripts/build_targets.sh --type=lint
53 changes: 31 additions & 22 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,42 @@ on:
release:
types: [created]

defaults:
run:
shell: bash -leo pipefail {0}

jobs:
build:
name: Attach firmware to release
runs-on: ubuntu-22.04
container:
image: ghcr.io/shanteacontrols/opendeck:latest
options: --user root
runs-on: ubuntu-latest
steps:
- name: Mark repository as safe
run: git config --global --add safe.directory /__w/OpenDeck/OpenDeck
- name: Pull the repository and submodules
- name: Pull the repository
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Build
run: |
git fetch --tags
./scripts/build_targets.sh --type=build
./scripts/copy_release_binaries.sh --build-dir=build --copy-dir=release
- name: Upload
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup missing directories and files on the runner
run: |
tag_name="${GITHUB_REF##*/}"
hub release edit $(find ./release -type f -printf "-a %p ") -m "" "$tag_name"
mkdir -p ~/.ssh
touch ~/.gitconfig
- name: Prepare container
uses: devcontainers/[email protected]
with:
imageName: opendeck # Local name only
imageTag: latest # Local tag only
push: never
env: |
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
- name: Build and upload
uses: devcontainers/[email protected]
with:
imageName: opendeck
imageTag: latest
push: never
runCmd: |
git fetch --tags
./scripts/build_targets.sh --type=build
./scripts/copy_release_binaries.sh --build-dir=build --copy-dir=release
tag_name="${GITHUB_REF##*/}"
hub release edit $(find ./release -type f -printf "-a %p ") -m "" "$tag_name"
16 changes: 0 additions & 16 deletions docker-compose-build.yml

This file was deleted.

14 changes: 0 additions & 14 deletions docker-compose.yml

This file was deleted.

41 changes: 0 additions & 41 deletions scripts/dev.sh

This file was deleted.

0 comments on commit 644cd63

Please sign in to comment.