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

Slash and burn: build complexity begone! #284

Merged
merged 30 commits into from
Aug 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d0523f6
No more FW8 branches
rmunn Aug 18, 2022
75f0a4b
Slash and burn: complexity begone!
rmunn Aug 18, 2022
6928646
Rely entirely on dotnet restore for packages
rmunn Aug 18, 2022
f8dd9c3
Get unit tests running
rmunn Aug 18, 2022
07e3713
Slash and burn: mono5-sil et al, begone!
rmunn Aug 18, 2022
06a1a68
Have pbuild.sh create base images directly
rmunn Aug 18, 2022
dd21a62
Slash and burn: LfMerge.proj, begone! Hurrah!
rmunn Aug 18, 2022
0f8707a
No longer need to keep NuGet packages in build dir
rmunn Aug 18, 2022
8dc75e1
Slash and burn: build complexity begone!
rmunn Aug 18, 2022
1ea67e7
Slash and burn: most of environ script, begone!
rmunn Aug 18, 2022
241c4f1
Mount user's home nuget folder as cache
rmunn Aug 18, 2022
5152959
Slightly simpler handling of SIL.Chorus.Mercurial
rmunn Aug 18, 2022
57c41bf
Honor TEST_SPEC env var in unit testing
rmunn Aug 19, 2022
a1f1a98
VS Code launch settings for debugging unit tests
rmunn Aug 19, 2022
ab5d11a
Stop caching in LfMergeSettings so unit tests work
rmunn Aug 19, 2022
90310f5
Fix nine more failing unit tests
rmunn Aug 19, 2022
aefe043
Allow testing uncommitted code
rmunn Aug 19, 2022
ba6c819
Remove lfmerge.conf (replaced by env vars)
rmunn Aug 19, 2022
b17ddf0
Remove rsyslog from final Dockerfile
rmunn Aug 19, 2022
20e839d
Use same checkout action in entire GHA workflow
rmunn Aug 19, 2022
1fce995
Remove entire calculate-branches build step
rmunn Aug 19, 2022
0cc5424
Remove unnecessary step from release workflow
rmunn Aug 19, 2022
0f1ba67
Run build directly in repo (no more copying)
rmunn Aug 19, 2022
c8312f5
Add sanity check to installation script
rmunn Aug 19, 2022
4ca0a46
Fix workflow syntax error
rmunn Aug 19, 2022
318dca9
Remove previous installation files if they exist
rmunn Aug 19, 2022
5e8f346
Update README with new build instructions
rmunn Aug 19, 2022
8bc4e8c
Remove unused lines from LfMerge.sln
rmunn Aug 19, 2022
d6bbedc
Delete MonoDevelopProperties from LfMerge.sln
rmunn Aug 19, 2022
ece4e67
Remove unneeded test filter in .vscode/tasks.json
rmunn Aug 19, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,8 @@ on:
workflow_dispatch:

jobs:
calculate_branches:
runs-on: ubuntu-latest
steps:
- name: Check out current branch
uses: actions/checkout@v3.0.2
with:
fetch-depth: 0 # All history for all tags and branches, since branch calculation step needs that

- name: Calculate branches to build
run: |
echo "${GITHUB_REF}"
./calculate-branches.sh --no-fw8 | grep FW9Branch >> "${GITHUB_ENV}"

- name: Save branch names in output
id: branches_to_build
run: |
echo "FW9Branch=${FW9Branch}"
echo "::set-output name=FW9Branch::${FW9Branch}"

outputs:
FW9Branch: ${{ steps.branches_to_build.outputs.FW9Branch }}

build:
runs-on: ubuntu-latest
needs: calculate_branches

# As of 2022-08-16, we build LfMerge for LCM DB version 72 only (and will expand this to include any future DbVersions)
strategy:
Expand All @@ -48,13 +25,6 @@ jobs:
with:
fetch-depth: 0 # All history for all tags and branches, since version number script needs that

- name: Verify current branch
run: |
git branch --contains HEAD --format '%(refname)'
echo FW9 was "${FW9Branch}"
env:
FW9Branch: ${{ needs.calculate_branches.outputs.FW9Branch }}

- name: Calculate version number
id: version
env:
Expand Down Expand Up @@ -108,9 +78,6 @@ jobs:
InformationalVersion: ${{ steps.version.outputs.InformationalVersion }}
run: docker run --mount type=bind,source="$(pwd)",target=/home/builder/repo --env "BUILD_NUMBER=${BUILD_NUMBER}" --env "DebPackageVersion=${DebPackageVersion}" --env "Version=${MsBuildVersion}" --env "MajorMinorPatch=${MajorMinorPatch}" --env "AssemblyVersion=${AssemblySemVer}" --env "FileVersion=${AssemblySemFileVer}" --env "InformationalVersion=${InformationalVersion}" --name tmp-lfmerge-build-${{matrix.dbversion}} lfmerge-build-${{matrix.dbversion}}

- name: Collect tarball images
run: docker container cp tmp-lfmerge-build-${{matrix.dbversion}}:/home/builder/packages/lfmerge/tarball ./

- name: Compress tarball images for faster uploads
run: time (tar cf - tarball | gzip -c9 > tarball.tar.gz)

Expand All @@ -121,12 +88,10 @@ jobs:
outputs:
MsBuildVersion: ${{ steps.output_version_number.outputs.VersionFor7000072 }}
TagFor7000072: ${{ steps.output_version_number.outputs.TagFor7000072 }}
FW9Branch: ${{ needs.calculate_branches.outputs.FW9Branch }}

release:
needs: build
uses: ./.github/workflows/release.yml
with:
MsBuildVersion: ${{ needs.build.outputs.MsBuildVersion }}
TagFor7000072: ${{ needs.build.outputs.TagFor7000072 }}
FW9Branch: ${{ needs.build.outputs.FW9Branch }}
18 changes: 2 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ on:
MsBuildVersion:
required: true
type: string
FW9Branch:
required: true
type: string
TagFor7000072:
required: true
type: string
Expand All @@ -18,7 +15,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2.4.0
- uses: actions/checkout@v3.0.2
with:
fetch-depth: 0

Expand All @@ -31,12 +28,11 @@ jobs:
- name: Tag release branches
if: github.event_name == 'push' && github.ref == 'refs/heads/live'
env:
FW9Branch: ${{ inputs.FW9Branch }}
TAG72: ${{ inputs.TagFor7000072 }}
run: |
git config --global user.name "github-actions"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag -f -a -m "Release ${TAG72}" "${TAG72}" "refs/remotes/origin/${FW9Branch}"
git tag -f -a -m "Release ${TAG72}" "${TAG72}" "refs/remotes/origin/live"
git push -v origin "${TAG72}"

- name: Download build artifacts
Expand All @@ -54,16 +50,6 @@ jobs:
- name: Verify that uncompress step worked
run: ls -lR tarball

- name: Restore executable bits
# GitHub artifacts system strips executable bits, so restore them here
# TODO: Now that we upload .tar.gz format, no longer needed since tar format preserves Unix permissions. Verify, then remove this section
run: |
chmod +x tarball/lfmerge*/usr/bin/lfmerge
chmod +x tarball/lfmerge*/usr/bin/lfmergeqm
chmod +x tarball/lfmerge*/usr/lib/lfmerge/*/chorusmerge
chmod +x tarball/lfmerge*/usr/lib/lfmerge/*/startlfmerge
chmod +x tarball/lfmerge*/usr/lib/lfmerge/*/Mercurial/hg

- name: Login to GHCR
if: github.event_name == 'push' && github.ref == 'refs/heads/live'
uses: docker/login-action@v1
Expand Down
33 changes: 6 additions & 27 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,10 @@
}
},
*/
{
"name": "Launch unit tests",
"env": {
// Display on main display :0, or on a Xephyr :2.
"DISPLAY": ":0",
// When launching LfMerge, use this mono.
"PATH": "/opt/mono5-sil/bin:${env:PATH}",
// Path to the rest of the necessary enviromnent settings for LfMerge. This is handled by a mono wrapper script in /opt.
"MONO_ENVIRON": "${workspaceRoot}/environ"
},
"type": "mono",
"request": "launch",
"program": "${workspaceRoot}/packages/NUnit.Runners.Net4.2.6.4/tools/nunit.exe",
"args": [
"LfMerge.Core.Tests.dll"
],
"cwd": "${workspaceRoot}/output/Debug",
"console": "integratedTerminal"
},
{
"name": "Attach",
"type": "mono",
"request": "attach",
"address": "localhost",
"port": 55555
}
]
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
},
]
}
47 changes: 47 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "shell",
"args": [
"build",
// Ask dotnet build to generate full paths for file names.
"/property:GenerateFullPaths=true",
// Do not generate summary otherwise it leads to duplicate errors in Problems panel
"/consoleloggerparameters:NoSummary"
],
"group": "build",
"presentation": {
"reveal": "silent"
},
"problemMatcher": "$msCompile"
},
{
"label": ".NET Core Test with debugger",
"type": "process",
"isBackground": true,
"command": "dotnet",
"args": [ "test" ],
"options":
{
"cwd": "${workspaceFolder}",
"env":
{
"VSTEST_HOST_DEBUG": "1"
},
},
"group": "test", "presentation":
{
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared"
},
"problemMatcher": []
},
]
}
46 changes: 15 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,51 +9,35 @@ RUN test -n "$BUILDER_UID"
ENV BUILDER_UID="$BUILDER_UID"

# # Build as a non-root user
RUN useradd -u "${BUILDER_UID:-DEFAULT_BUILDER_UID}" -d /home/builder -g users -G www-data,fieldworks,systemd-journal -m -s /bin/bash builder ; \
RUN useradd -u "${BUILDER_UID:-DEFAULT_BUILDER_UID}" -d /home/builder -g users -G www-data,fieldworks -m -s /bin/bash builder ; \
echo "builder ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers; \
chown -R builder:users /build

# Any setup unique to the various builds goes in one of these four images
FROM lfmerge-builder-base AS lfmerge-build-7000068
ENV DbVersion=7000068
ENV DBVERSIONPATH=/usr/lib/lfmerge/7000068
ENV RUN_UNIT_TESTS=0
ENV UPDATE_ASSEMBLYINFO_BY_SCRIPT=1
ENV NUNIT_VERSION_MAJOR=2
# To run specific unit tests, set TEST_SPEC env var, e.g.:
# ENV TEST_SPEC=LfMerge.Core.Tests.Actions.SynchronizeActionTests.SynchronizeAction_CustomReferenceAtomicField_DoesNotThrowExceptionDuringSync

FROM lfmerge-builder-base AS lfmerge-build-7000069
ENV DbVersion=7000069
ENV DBVERSIONPATH=/usr/lib/lfmerge/7000069
ENV RUN_UNIT_TESTS=0
ENV UPDATE_ASSEMBLYINFO_BY_SCRIPT=1
ENV NUNIT_VERSION_MAJOR=2
# ENV TEST_SPEC=LfMerge.Core.Tests.Actions.SynchronizeActionTests.SynchronizeAction_CustomReferenceAtomicField_DoesNotThrowExceptionDuringSync

FROM lfmerge-builder-base AS lfmerge-build-7000070
ENV DbVersion=7000070
ENV DBVERSIONPATH=/usr/lib/lfmerge/7000070
ENV RUN_UNIT_TESTS=0
ENV UPDATE_ASSEMBLYINFO_BY_SCRIPT=1
ENV NUNIT_VERSION_MAJOR=2
# ENV TEST_SPEC=LfMerge.Core.Tests.Actions.SynchronizeActionTests.SynchronizeAction_CustomReferenceAtomicField_DoesNotThrowExceptionDuringSync
# Any setup unique to one specific DbVersion build goes in one of the images below

FROM lfmerge-builder-base AS lfmerge-build-7000072
ENV DbVersion=7000072
ENV DBVERSIONPATH=/usr/lib/lfmerge/7000072
ENV RUN_UNIT_TESTS=0
ENV UPDATE_ASSEMBLYINFO_BY_SCRIPT=0
ENV NUNIT_VERSION_MAJOR=3
# ENV TEST_SPEC=LfMerge.Core.Tests.Actions.SynchronizeActionTests.SynchronizeAction_CustomReferenceAtomicField_DoesNotThrowExceptionDuringSync

FROM lfmerge-build-${DbVersion} AS lfmerge-build

# So unit tests can run
RUN mkdir -p /var/lib/languageforge/lexicon/sendreceive/ \
&& cd /var/lib/languageforge/lexicon/sendreceive/ && mkdir Templates state editqueue syncqueue webwork && cd - \
&& chown -R builder:users /var/lib/languageforge/lexicon/sendreceive

USER builder
WORKDIR /home/builder/repo
# Git repo should be mounted under /home/builder/repo when run
# E.g., `docker run --mount type=bind,source="$(pwd)",target=/home/builder/repo

# NuGet package cache dir should be bind-mounted from home of running user
# E.g., `docker run --mount type=bind,source="${HOME}/.nuget/packages",target=/home/builder/.nuget/packages
RUN mkdir -p /home/builder/.nuget/packages

# Git repo should be mounted under ${HOME}/packages/lfmerge when run
# E.g., `docker run --mount type=bind,source="$(pwd)",target=/home/builder/packages/lfmerge`
RUN mkdir -p /home/builder/repo /home/builder/packages/lfmerge
CMD /home/builder/repo/docker/scripts/build-and-test.sh ${DbVersion}
CMD docker/scripts/build-and-test.sh ${DbVersion}
# CMD doesn't actually run the script, it just gives `docker run` a default.
# So it's okay for the Git repo to not be mounted yet.
9 changes: 1 addition & 8 deletions Dockerfile.builder-base
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,9 @@ WORKDIR /build/lfmerge

ENV DEBIAN_FRONTEND=noninteractive
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1
RUN apt-get update && apt-get install -y gnupg

COPY sil-packages-key.gpg .
COPY sil-packages-testing-key.gpg .
RUN apt-key add sil-packages-key.gpg
RUN apt-key add sil-packages-testing-key.gpg
RUN echo 'deb http://linux.lsdev.sil.org/ubuntu bionic main' > /etc/apt/sources.list.d/llso-experimental.list
RUN echo 'deb http://linux.lsdev.sil.org/ubuntu bionic-experimental main' >> /etc/apt/sources.list.d/llso-experimental.list
# Dependencies from Debian "control" file
RUN apt-get update && apt-get install -y sudo debhelper devscripts cli-common-dev iputils-ping cpp python-dev pkg-config mono5-sil mono5-sil-msbuild libicu-dev lfmerge-fdo && rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y curl sudo iputils-ping cpp python-is-python2 python2-dev pkg-config libicu-dev && rm -rf /var/lib/apt/lists/*

# Ensure fieldworks group exists in case lfmerge-fdo package didn't install it, and that www-data is part of that group
# Also ensure that www-data has a .local dir in its home directory (/var/www) since some of lfmerge's dependencies assume that $HOME/.local exists
Expand Down
14 changes: 3 additions & 11 deletions Dockerfile.finalresult
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,19 @@ FROM ghcr.io/sillsdev/lfmerge-base:runtime
# install LFMerge prerequisites
# tini - PID 1 handler
# python - required by Mercurial, which is bundled in the LFMerge installation
# rsyslog - lfmerge logs to rsyslog and expects this to exist
# rsyslog customizations (imklog reads kernel messages, which isn't allowed or desired in Docker containers)
# logrotate - ensure logs won't grow without bound, and that old logs get cleaned up automatically
# iputils-ping - Chorus (part of LFMerge) requires the "ping" command to be available on the command line
# less - so we can read syslog during manual debugging of issues
# vim-tiny - so we can edit state files (to change HOLD to IDLE) during manual debugging of issues
RUN curl -L http://linux.lsdev.sil.org/downloads/sil-testing.gpg | apt-key add - \
&& echo "deb http://linux.lsdev.sil.org/ubuntu bionic main" > /etc/apt/sources.list.d/linux-lsdev-sil-org.list \
&& apt-get update \
&& apt-get install --yes --no-install-recommends tini python rsyslog logrotate iputils-ping inotify-tools less vim-tiny \
&& rm -rf /var/lib/apt/lists/* \
&& sed -i '/load="imklog"/s/^/#/' /etc/rsyslog.conf
RUN apt-get update \
&& apt-get install --yes --no-install-recommends tini python iputils-ping inotify-tools less vim-tiny \
&& rm -rf /var/lib/apt/lists/*

ADD tarball/lfmerge* /

RUN mkdir -m 02775 -p /var/lib/languageforge/lexicon/sendreceive/syncqueue /var/lib/languageforge/lexicon/sendreceive/webwork /var/lib/languageforge/lexicon/sendreceive/Templates /var/lib/languageforge/lexicon/sendreceive/state && chown -R www-data:www-data /var/lib/languageforge

RUN install -d -o www-data -g www-data -m 02775 /var/run/lfmerge

# TODO: Turn this into environment variables, because we want to be able to just set env vars in k8s config and restart the container
COPY lfmerge.conf /etc/languageforge/conf/sendreceive.conf
COPY sudoers.d.lfmerge.conf /etc/sudoers.d/lfmerge
COPY mercurial-cacerts.rc /etc/mercurial/hgrc
COPY lfmergeqm-background.sh /
Expand Down
9 changes: 1 addition & 8 deletions Dockerfile.runtime-base
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,9 @@ WORKDIR /build/lfmerge

ENV DEBIAN_FRONTEND=noninteractive
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1
RUN apt-get update && apt-get install -y gnupg

COPY sil-packages-key.gpg .
COPY sil-packages-testing-key.gpg .
RUN apt-key add sil-packages-key.gpg
RUN apt-key add sil-packages-testing-key.gpg
RUN echo 'deb http://linux.lsdev.sil.org/ubuntu bionic main' > /etc/apt/sources.list.d/llso-experimental.list
RUN echo 'deb http://linux.lsdev.sil.org/ubuntu bionic-experimental main' >> /etc/apt/sources.list.d/llso-experimental.list
# Dependencies from Debian "control" file
RUN apt-get update && apt-get install -y sudo debhelper devscripts cli-common-dev iputils-ping cpp python-dev pkg-config mono5-sil mono5-sil-msbuild libicu-dev lfmerge-fdo && rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y curl sudo iputils-ping cpp python-is-python2 python2-dev pkg-config libicu-dev && rm -rf /var/lib/apt/lists/*

# Ensure fieldworks group exists in case lfmerge-fdo package didn't install it, and that www-data is part of that group
# Also ensure that www-data has a .local dir in its home directory (/var/www) since some of lfmerge's dependencies assume that $HOME/.local exists
Expand Down
Loading