Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: initial commit #69

Closed
wants to merge 14 commits into from
52 changes: 52 additions & 0 deletions .github/workflows/compilation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: CI-compile

on:
push:
pull_request:

jobs:
build:
runs-on: ubuntu-latest
container: ghcr.io/frno7/mipsr5900el-gentoo-linux-gnu:main
steps:
- uses: actions/checkout@v3

- name: Compile project
env:
INSTALL_MOD_PATH: ../initramfs/ps2/
INSTALL_MOD_STRIP: 1
run: |
mv -f /srv/initramfs ../
make -j $(getconf _NPROCESSORS_ONLN) ps2_defconfig
make -j $(getconf _NPROCESSORS_ONLN) oldconfig
make -j $(getconf _NPROCESSORS_ONLN) vmlinux
make -j $(getconf _NPROCESSORS_ONLN) modules
make -j $(getconf _NPROCESSORS_ONLN) modules_install
make -j $(getconf _NPROCESSORS_ONLN) vmlinuz
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't these steps done in

https://github.com/frno7/mipsr5900el-gentoo-linux-gnu/blob/9e01f44b0d5e04a496c8ac27e13494bf208eb63a/Dockerfile#L49-L55

already? I agree that they're better placed here, but then I suppose we should remove them from the mipsr5900el-gentoo-linux-gnu repo? Does it make sense to make the Dockers more modular, so that QEMU would be built only in the qemu repo, and so on?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a big philosophical question :D Docker image currently is so unoptimized, that it is almost 3.5Gb in size and 1.7Gb reserved only for kernel sources. I made a Docker image to hold All-In-One inside one container, so everyone can download it and make a fast kernel compilation on his machine just by typing cd /srv/kernel; make vmlinuz. As about this Github Action, I agree that it is doing "double work", but I don't see that this is a problem. Docker contains Linux kernel from the past, but Github Action compiles an actively developed branch that can be more actual.
Anyway, I don't think that this action should be affected by this. You probably should create an issue in the Docker container repository for possible removing kernel sources from the container.

Does it make sense to make the Dockers more modular, so that QEMU would be built only in the qemu repo, and so on?

It can make sense, but it is difficult to calculate necessary dependencies. It is much easier to hold everything inside an all-in-one container than to manage dependency calculations for each repository. This container can be overkill for most repoes, but it is much easier to maintain. And it will be faster to complete cause all utilities are already precompiled inside the container.
Maybe only the kernel itself can be removed from container, cause it is very big and probably will not be dpendent for other things (except of initramfs of course, I mainly included it there for easier intiramfs managing).

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, let's celebrate this package achievement now, and tune things later as we go along. Will you push the branch name thing mentioned in #69 (comment) before we merge this? With the frno7/gentoo-mipsr5900el@9e01f44 fix in, chances are that it'll actually boot nice and proper. :-)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am outof my pc, will be able to look at itinfew hours

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... Initialize containers fails with invalid reference format: repository name must be lowercase. It seems github.ref evaluates to refs/heads/ps2-main, which having / won’t work as a branch name. We’d need to get rid of the refs/heads/ prefix. A need for a substring function, again. :-)

Environment files seems to offer a solution. Adapting its example, something like

steps:
  - name: Obtain file tag from branch and commit
    id: obtain_file_tag
    run: |
      echo "FILE_TAG=${GITHUB_REF#refs/*/}-${GITHUB_SHA:0:8}" >> $GITHUB_ENV
  - name: Echo file tag
    id: echo_file_tag
    run: |
      echo "${{ env.FILE_TAG }}" # Should output "ps2-main-dc19f33e" or suchlike

where ${GITHUB_REF#refs/*/} (shortest matching pattern deleted) and ${GITHUB_SHA:0:8} (substring expansion) are Bash parameter expansion rules.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the documentation for GITHUB_REF it’s

The branch or tag ref that triggered the workflow run. For branches this is the format refs/heads/<branch_name>, for tags it is refs/tags/<tag_name>, and for pull requests it is refs/pull/<pr_number>/merge. This variable is only set if a branch or tag is available for the event type. For example, refs/heads/feature-branch-1.

A problematic case will be pull requests with refs/pull/<pr_number>/merge having triple /. We could use ${GITHUB_REF##refs/*/} with ## serving as the longest matching pattern deleted rather than the shortest with a single #. It’ll evaluate refs/pull/17/merge to merge, rather than 17/merge, which wouldn’t work with /. Another, more useful alternative, would be to have FILE_TAG become pull-17, 17-merge, or pull-17-merge. :-)

cp vmlinuz PS2Linux-${{ github.ref_name }}-${{ github.sha }}.ELF

- name: Upload kernel as artifact
if: ${{ success() }}
uses: actions/upload-artifact@v3
with:
name: "PS2Linux-${{ github.ref_name }}-${{ github.sha }}.ELF"
path: PS2Linux-${{ github.ref_name }}-${{ github.sha }}.ELF

- name: Upload initramfs as artifact
if: ${{ success() }}
uses: actions/upload-artifact@v3
with:
name: Initramfs
path: usr/initramfs_data.cpio*

- name: Upload kernel as pre-release
if: github.ref == 'refs/heads/ps2-main'
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: true
automatic_release_tag: "latest"
title: Development build
files: |
PS2Linux-${{ github.ref_name }}-${{ github.sha }}.ELF
usr/initramfs_data.cpio*
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ modules.order
!.gitattributes
!.gitignore
!.mailmap
!.github

#
# Generated include files
Expand Down