Skip to content

Commit

Permalink
Fix workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
0Tech committed Feb 14, 2024
1 parent 81e51b4 commit c4f0d32
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 23 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/module.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,33 @@ jobs:
go-lint:
name: go lint
runs-on: ubuntu-latest
timeout-minutes: ${{ inputs.timeout_minutes }}
timeout-minutes: ${{ inputs.timeout-minutes }}
steps:
- uses: actions/checkout@v4
- name: Configure
run: cmake -S . -B build -D USE_DOCKER=ON -D FIX_IS_ERROR=ON
run: cmake -S . -B build -D USE_DOCKER=ON -D UID=$(id -u) -D GID=$(id -g) -D FIX_IS_ERROR=ON
- name: Lint
run: cmake --build build --target go_lint_${{ env.target }}
go-build:
name: go build
runs-on: ubuntu-latest
timeout-minutes: ${{ inputs.timeout_minutes }}
timeout-minutes: ${{ inputs.timeout-minutes }}
steps:
- uses: actions/checkout@v4
- name: Configure
run: cmake -S . -B build -D USE_DOCKER=ON -D FIX_IS_ERROR=ON
run: cmake -S . -B build -D USE_DOCKER=ON -D UID=$(id -u) -D GID=$(id -g) -D FIX_IS_ERROR=ON
- name: Build
run: cmake --build build --target go_build_${{ env.target }}
go-test:
name: go test
runs-on: ubuntu-latest
timeout-minutes: ${{ inputs.timeout_minutes }}
timeout-minutes: ${{ inputs.timeout-minutes }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Configure
run: cmake -S . -B build -D USE_DOCKER=ON -D FIX_IS_ERROR=ON
run: cmake -S . -B build -D USE_DOCKER=ON -D UID=$(id -u) -D GID=$(id -g) -D FIX_IS_ERROR=ON
- name: Install builders
run: cmake --build build --target install_builders
- name: Test
Expand All @@ -63,20 +63,20 @@ jobs:
buf-format:
name: buf format
runs-on: ubuntu-latest
timeout-minutes: ${{ inputs.timeout_minutes }}
timeout-minutes: ${{ inputs.timeout-minutes }}
steps:
- uses: actions/checkout@v4
- name: Configure
run: cmake -S . -B build -D USE_DOCKER=ON -D FIX_IS_ERROR=ON
run: cmake -S . -B build -D USE_DOCKER=ON -D UID=$(id -u) -D GID=$(id -g) -D FIX_IS_ERROR=ON
- name: Lint
run: cmake --build build --target buf_format_${{ env.target }}
buf-lint:
name: buf lint
runs-on: ubuntu-latest
timeout-minutes: ${{ inputs.timeout_minutes }}
timeout-minutes: ${{ inputs.timeout-minutes }}
steps:
- uses: actions/checkout@v4
- name: Configure
run: cmake -S . -B build -D USE_DOCKER=ON -D FIX_IS_ERROR=ON
run: cmake -S . -B build -D USE_DOCKER=ON -D UID=$(id -u) -D GID=$(id -g) -D FIX_IS_ERROR=ON
- name: Lint
run: cmake --build build --target buf_lint_${{ env.target }}
2 changes: 1 addition & 1 deletion .github/workflows/modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
pull_request:
jobs:
check-modules:
name: check modules
name: x/${{ matrix.name }}
strategy:
matrix:
include:
Expand Down
9 changes: 6 additions & 3 deletions builders/docker/install/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
configure_file(Dockerfile.in Dockerfile
@ONLY
configure_file(Dockerfile Dockerfile
COPYONLY
)

set(UID 1000 CACHE STRING "uid of the user")
set(GID 1000 CACHE STRING "gid of the user")

function(_get_builder_binary_dir _output)
file(RELATIVE_PATH _rel_builder_source_dir ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_FUNCTION_LIST_DIR})
file(REAL_PATH ${_rel_builder_source_dir} ${_output} BASE_DIRECTORY ${CMAKE_BINARY_DIR})
return(PROPAGATE ${_output})
endfunction()

add_custom_target(install_builders
COMMAND cmake -D IDFILE=id.txt -P ${CMAKE_CURRENT_SOURCE_DIR}/docker-build.cmake
COMMAND cmake -D IDFILE=id.txt -D UID=${UID} -D GID=${GID} -P ${CMAKE_CURRENT_SOURCE_DIR}/docker-build.cmake
)

file(COPY ${CMAKE_SOURCE_DIR}/go.work ${CMAKE_SOURCE_DIR}/go.work.sum
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ RUN cmake -S . -B build -Wno-dev && cmake --build build --target install_builder

FROM platform AS final

ARG uid=1000
ARG gid=1000
ARG UID
ARG GID

RUN addgroup --system --gid ${gid} builder
RUN adduser --system --uid ${uid} --gid ${gid} builder --home /home/builder
RUN addgroup --system --gid ${GID} builder
RUN adduser --system --uid ${UID} --gid ${GID} builder --home /home/builder

COPY --from=builders /usr/local /usr/local/
COPY --from=builders --chown=${uid}:${gid} /root/go /home/builder/go/
COPY --from=builders --chown=${UID}:${GID} /root/go /home/builder/go/

ENV PATH /home/builder/go/bin:/usr/local/bin:/usr/bin

WORKDIR /tmp/mods
RUN chown ${uid}:${gid} .
COPY --chown=${uid}:${gid} mods .
RUN chown ${UID}:${GID} .
COPY --chown=${UID}:${GID} mods .

USER ${uid}:${gid}
USER ${UID}:${GID}
RUN go mod download
2 changes: 1 addition & 1 deletion builders/docker/install/docker-build.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
execute_process(
COMMAND docker build -q .
COMMAND docker build --build-arg UID=${UID} --build-arg GID=${GID} -q .
OUTPUT_VARIABLE id
)
string(STRIP ${id} id)
Expand Down

0 comments on commit c4f0d32

Please sign in to comment.