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

Major CI Improvements #901

Merged
merged 78 commits into from Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
1199b8b
Add ccache to github actions builds
BertrandD Jul 22, 2022
88990bc
incrase cache size
BertrandD Jul 22, 2022
5f38d1a
Add ccache to buildInputs
BertrandD Aug 9, 2022
bc379b2
Try to remove nix to build & run tests
BertrandD Aug 23, 2022
1220678
run on all branches on push
BertrandD Aug 23, 2022
f7b2fc1
run on all branches on push
BertrandD Aug 23, 2022
e24c974
fix image name
BertrandD Aug 23, 2022
6da4efb
use other credentials ?
BertrandD Aug 23, 2022
e48fce2
fix cli
BertrandD Aug 23, 2022
0a17f0d
Use ninja
BertrandD Aug 23, 2022
516d159
Use sys ssl
BertrandD Aug 23, 2022
05a3899
add postgres service
BertrandD Aug 23, 2022
083b548
temporarily change url for tests
BertrandD Aug 23, 2022
860f2c5
build postgres url from env
BertrandD Aug 23, 2022
17bbb8b
Add macos build
BertrandD Sep 1, 2022
4fd4ac6
Try to fix macos build
BertrandD Sep 1, 2022
f0e578b
Upload cmake artifacts
BertrandD Sep 1, 2022
f51407b
add PGsql include dir
BertrandD Sep 1, 2022
4cb164e
Rollback to pg 13
BertrandD Sep 1, 2022
415d1e2
Rollback to pg 13 on macos
BertrandD Sep 1, 2022
2fc8c2a
Rollback to pg 13 on macos
BertrandD Sep 1, 2022
371f59a
Enable unixes
BertrandD Sep 1, 2022
b974a4b
Cancel previous macos runs
BertrandD Sep 1, 2022
77c9260
Remove ccache from nix_release_builds.yml
BertrandD Sep 1, 2022
6cc934f
don't use sys openssl on macos
BertrandD Sep 2, 2022
9840d93
Revert "don't use sys openssl on macos"
BertrandD Sep 2, 2022
c44d94e
fix db connection on macos
BertrandD Sep 2, 2022
b245163
fix incldue path
BertrandD Sep 2, 2022
52186d9
Merge branch 'fix_macos_build' into ci_improvements
BertrandD Sep 2, 2022
8b8c47e
Keep circleci only on main
BertrandD Sep 2, 2022
63a85d3
remove appveyor.yml
BertrandD Sep 2, 2022
2e27ca2
run clang-format-check only on push & cancel previsou runs
BertrandD Sep 2, 2022
4f3ba11
Add more parameters to release workflow
BertrandD Sep 2, 2022
4bbe566
fix workflow condition syntax
BertrandD Sep 2, 2022
93a2d76
don't run nix_release_builds.yml on branches except manually asked for
BertrandD Sep 2, 2022
d46bb51
Rename build
BertrandD Sep 2, 2022
c5c1830
Add jar package workflow
BertrandD Sep 2, 2022
86a254d
Pass secrets
BertrandD Sep 2, 2022
f7d3759
executable scripts
BertrandD Sep 2, 2022
f69b235
Publish to WD
BertrandD Sep 2, 2022
f2dbb81
update ccache keys
BertrandD Sep 2, 2022
0fe58ae
fix secret for publish & call publish workflow on Release
BertrandD Sep 2, 2022
78dbaf8
fix need dependency
BertrandD Sep 2, 2022
4acd61e
fix checkout
BertrandD Sep 2, 2022
dce82c6
fix checkout
BertrandD Sep 2, 2022
bf00e1f
reorder checkout to avoid clean
BertrandD Sep 2, 2022
dd7772b
fetch ?
BertrandD Sep 2, 2022
49b6e1e
fix checkout
BertrandD Sep 2, 2022
70890ba
add some debug command to understand what is going on here
BertrandD Sep 2, 2022
9606dfa
do not update submodule for now
BertrandD Sep 2, 2022
cc5577c
add missing env var
BertrandD Sep 2, 2022
4082100
update token
BertrandD Sep 5, 2022
f302b62
Update version numbers
BertrandD Sep 5, 2022
a3773be
print more
BertrandD Sep 5, 2022
135dd3c
print more
BertrandD Sep 5, 2022
0b80205
fix empty var
BertrandD Sep 5, 2022
235be22
update sbt version
BertrandD Sep 5, 2022
9efb9c6
Add script to publish jar locally
BertrandD Sep 5, 2022
2408538
Don't use unique version number for snapshots
BertrandD Sep 5, 2022
d46d8c0
try to build in release instead of debug
BertrandD Sep 6, 2022
f099ea2
some cleanings & version set
BertrandD Sep 6, 2022
7d67b29
Revert "Don't use unique version number for snapshots"
BertrandD Sep 6, 2022
637ad3b
remove job to create WD PR
BertrandD Sep 6, 2022
9b4785b
run linting only if updating code
BertrandD Sep 6, 2022
74d9b11
print for debug
BertrandD Sep 6, 2022
a41c6ea
fix clang tidy condition
BertrandD Sep 6, 2022
a6ddded
clang format on pull requests only
BertrandD Sep 6, 2022
fe0d9a8
Revert "remove job to create WD PR"
BertrandD Sep 7, 2022
1432199
Create PR with bump of jar version
BertrandD Sep 7, 2022
6f65d63
Revert "Create PR with bump of jar version"
BertrandD Sep 7, 2022
7c65dd9
fix sigpipe error
BertrandD Sep 7, 2022
8b1e516
Publish to WD on manual release
BertrandD Sep 8, 2022
eb432e2
Rollback unused changes
BertrandD Sep 8, 2022
098b9ea
Add documentation
BertrandD Sep 8, 2022
5c3ebad
Run package only manually & on call
BertrandD Sep 8, 2022
d7d0d7d
Update build env
BertrandD Sep 8, 2022
e3cb2cf
clean unused changes
BertrandD Sep 8, 2022
d026d15
Update after review
BertrandD Sep 8, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/build_lib.sh
Expand Up @@ -10,7 +10,7 @@ unamestr=`uname`
export ARCH=$2
export CMAKE=cmake
export PATH=$PATH:~/cmake_folder/bin
export PG_INCLUDE_DIR=`[[ "$unamestr" = "Darwin" ]] && echo -n "/usr/local/opt/postgresql/include" || echo -n "/usr/include/postgresql"`
export PG_INCLUDE_DIR=`[[ "$unamestr" = "Darwin" ]] && echo -n "/usr/local/opt/postgresql@13/include" || echo -n "/usr/include/postgresql"`

echo "Use $PG_INCLUDE_DIR for PGSQL"

Expand Down
18 changes: 15 additions & 3 deletions .circleci/config.yml
Expand Up @@ -242,6 +242,8 @@ workflows:
- build_linux_release:
<<: *default_context
filters:
branches:
only: main
tags:
only: /.*/
- build_linux_jni_release:
Expand All @@ -250,27 +252,37 @@ workflows:
tags:
only: /.*/
branches:
only: /^(?!pull\/).*$/
only: main
- build_macos_release:
<<: *default_context
filters:
tags:
only: /.*/
branches:
only: main
- build_macos_jni_release:
<<: *default_context
filters:
tags:
only: /.*/
branches:
only: /^(?!pull\/).*$/
only: main
- build_linux_debug:
<<: *default_context
filters:
branches:
only: main
- build_macos_debug:
<<: *default_context
filters:
branches:
only: main
- publish_jar:
requires:
- build_linux_jni_release
- build_macos_jni_release
filters:
tags:
only: /.*/
only: /.*/
branches:
only: main
4 changes: 2 additions & 2 deletions .circleci/setup_macos.sh
Expand Up @@ -33,8 +33,8 @@ brew install --build-from-source cmake

echo "========> Install PostgreSQL"
# Install with verbose otherwise the setup may timeout the CI because it doesn't log.
brew install --verbose postgresql
export CPLUS_INCLUDE_PATH="/usr/local/Cellar/postgresql/12.3_4/include:$CPLUS_INCLUDE_PATH"
brew install --verbose postgresql@13
brew link --overwrite postgresql@13


echo "========> Install Sqlite"
Expand Down
10 changes: 10 additions & 0 deletions .github/scripts/build.sh
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -euo pipefail

mkdir _build_tests
cd _build_tests
cmake .. -DTARGET_JNI=${BUILD_JNI-OFF} -DBUILD_TESTS=ON -DNIX_BUILD=OFF -DCCACHE=ON -DSYS_OPENSSL=ON -DOPENSSL_USE_STATIC_LIBS=TRUE -GNinja
echo "========= Building libcore"
cmake --build . --parallel --target ledger-core-static
cmake --build . --parallel --target ledger-core
cmake --build . --parallel
19 changes: 19 additions & 0 deletions .github/scripts/publish_to_wd.sh
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -euo pipefail

cd $GITHUB_WORKSPACE/ledger-wallet-daemon

# Bump libcore version
sed -i -E 's/(val libcore *= *\")(.*)\"/\1'$VERSION'\"/' build.sbt

# Commit & push changes
git checkout -b bump_libcore_$VERSION
git add lib # libcore
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git commit -m "Bump libcore to $VERSION"
git push --set-upstream origin bump_libcore_$VERSION
gh pr create --title "Bump libcore to $VERSION" \
--body "Automatic update from libcore release" \
--base main \
--head bump_libcore_$VERSION
5 changes: 5 additions & 0 deletions .github/scripts/test.sh
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -euo pipefail

cd _build_tests
ctest --output-on-failure
11 changes: 10 additions & 1 deletion .github/workflows/clang-format-check.yml
@@ -1,10 +1,19 @@
name: clang-format Check
on: [push, pull_request]
on:
pull_request:
paths:
- core/**
- .clang-format
- .github/workflows/clang-format-check.yml
jobs:
formatting-check:
name: Formatting Check
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v2
- name: Run clang-format style check for C/C++/Protobuf programs.
uses: jidicula/clang-format-action@v4.5.0
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/clang-tidty-review.yml
@@ -1,5 +1,10 @@
name: "Clang-tidy Code Review"
on: [pull_request]
on:
pull_request:
paths:
- core/**
- .clang-tidy
- .github/workflows/clang-tidy-review.yml

jobs:
build:
Expand Down
112 changes: 39 additions & 73 deletions .github/workflows/nix_release_builds.yml
@@ -1,30 +1,28 @@
name: "Nix Release builds"
name: "Package libcore"
on:
pull_request:
branches:
- main
- release/4.0.0
- release/4.1.0
- release/4.2.0
- develop
push:
branches:
- main
- release/4.0.0
- release/4.1.0
- release/4.2.0
- develop
tags:
- '*'
workflow_run:
workflows: ["Release libcore"]
types:
- completed
workflow_dispatch:
inputs:
release:
description: Create Release JAR package (instead of SNAPSHOT). Version number will be taken from CMakeLists.txt
required: true
type: boolean
default: false
version:
description: Custom version of jar package (applies only if `release` is true)
required: false
type: string
workflow_call:
inputs:
release:
required: false
type: boolean
version:
required: false
type: string
jobs:
libcore_version:
name: Compute libcore version
runs-on: ubuntu-latest
if: ${{ github.event_name != "workflow_run" || github.event.workflow_run.conclusion == 'success' }}
outputs:
lib_version: ${{ steps.lib_version.outputs.lib_version }}
deploy_dynlibs: ${{ steps.lib_version.outputs.deploy_dynlibs }}
Expand All @@ -38,53 +36,25 @@ jobs:
# https://github.com/actions/checkout/blob/v2.3.4/README.md
- name: Set version slug and push_to_S3 flags
id: lib_version
run: bash nix/scripts/export_libcore_version.sh ${{ github.event.pull_request.head.ref }}
Ubuntu_jni:
name: Linux (with JNI)
needs: libcore_version
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v2.3.4
with:
submodules: 'recursive'
- uses: cachix/install-nix-action@v14.1
with:
nix_path: nixpkgs=https://github.com/NixOS/nixpkgs/archive/5f746317f10f7206f1dbb8dfcfc2257b04507eee.tar.gz
- run: nix-build
- uses: actions/upload-artifact@v2
with:
name: ${{ needs.libcore_version.outputs.lib_version }}-linux-libledgercore
path: result/lib/libledger-core.so
retention-days: 30
MacOS_jni:
name: MacOS (with JNI)
needs: libcore_version
runs-on: macos-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v2.3.4
with:
submodules: 'recursive'
- uses: cachix/install-nix-action@v14.1
with:
nix_path: nixpkgs=https://github.com/NixOS/nixpkgs/archive/5f746317f10f7206f1dbb8dfcfc2257b04507eee.tar.gz
- run: nix-build
- uses: actions/upload-artifact@v2
with:
name: ${{ needs.libcore_version.outputs.lib_version }}-macos-libledgercore
path: result/lib/libledger-core.dylib
retention-days: 30
run: bash nix/scripts/export_libcore_version.sh
env:
RELEASE: ${{ inputs.release || 'false' }}
VERSION: ${{ inputs.version }}
Build_Release_JNI:
name: Build Release with JNI
uses: ./.github/workflows/tests.yml
secrets: inherit # pass all secrets
with:
buildJni: 'ON'
JAR:
name: Jar build (MacOS + Linux)
needs: [Ubuntu_jni, MacOS_jni, libcore_version]
needs: [libcore_version, Build_Release_JNI]
runs-on: ubuntu-latest
container:
image: ghcr.io/ledgerhq/lib-ledger-core-build-env/lib-ledger-core-build-env:1.0.3
credentials:
username: ${{ secrets.CI_BOT_USERNAME }}
password: ${{ secrets.CI_BOT_TOKEN }}
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
Expand All @@ -93,23 +63,19 @@ jobs:
- uses: actions/checkout@v2.3.4
with:
submodules: 'recursive'
- uses: cachix/install-nix-action@v14.1
with:
nix_path: nixpkgs=https://github.com/NixOS/nixpkgs/archive/5f746317f10f7206f1dbb8dfcfc2257b04507eee.tar.gz
- run: mkdir -p jar_build/src/main/resources/resources/djinni_native_libs
- name: Fetch Linux so
uses: actions/download-artifact@v2
with:
name: ${{ needs.libcore_version.outputs.lib_version }}-linux-libledgercore
name: linux-ubuntu-22.04-libledgercore
path: jar_build/src/main/resources/resources/djinni_native_libs
- name: Fetch MacOS dylib
uses: actions/download-artifact@v2
with:
name: ${{ needs.libcore_version.outputs.lib_version }}-macos-libledgercore
name: macos-libledgercore
path: jar_build/src/main/resources/resources/djinni_native_libs
- run: nix-shell --run "bash nix/scripts/build_jar.sh" nix/libcore-jar.nix
- run: bash nix/scripts/build_jar.sh
env:
LIB_VERSION: ${{ needs.libcore_version.outputs.lib_version }}
GITHUB_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
JAR_VERSION: ${{ needs.libcore_version.outputs.jar_version }}
- uses: actions/upload-artifact@v2
Expand Down
50 changes: 45 additions & 5 deletions .github/workflows/release.yml
Expand Up @@ -3,20 +3,32 @@ on:
workflow_dispatch:
inputs:
version:
description: "Release version"
description: "Release version (tag)"
required: true
type: string
releaseNote:
description: "Should create a Release"
description: "Create a Github Release note"
required: true
type: boolean
default: true
preRelease:
description: "This is a pre-release"
required: true
type: boolean
default: false
draft:
description: "Save Release as draft"
required: true
type: boolean
default: false
jobs:
Release:
runs-on: ubuntu-22.04
env:
VERSION: ${{ github.event.inputs.version }}
RELEASE_NOTE: ${{ github.event.inputs.releaseNote }}
PRE_RELEASE: ${{ github.event.inputs.preRelease }}
DRAFT: ${{ github.event.inputs.draft }}
steps:
- uses: actions/checkout@v2.3.4
- name: Set version number
Expand All @@ -37,14 +49,42 @@ jobs:
script: |
try {
await github.rest.repos.createRelease({
draft: false,
draft: process.env.DRAFT,
generate_release_notes: true,
name: process.env.RELEASE_TAG,
owner: context.repo.owner,
prerelease: false,
prerelease: process.env.PRE_RELEASE,
repo: context.repo.repo,
tag_name: process.env.VERSION,
});
} catch (error) {
core.setFailed(error.message);
}
}
Build:
name: Build Release with JNI
uses: ./.github/workflows/nix_release_builds.yml
secrets: inherit # pass all secrets
needs: [ Release ]
with:
release: true
version: ${{ github.event.inputs.version }}
Publish:
name: Publish to WD
needs: [Build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
BertrandD marked this conversation as resolved.
Show resolved Hide resolved
name: Checkout libcore
- uses: actions/checkout@v3
name: Checkout wallet-daemont
with:
token: ${{ secrets.CI_BOT_TOKEN }}
repository: LedgerHQ/ledger-wallet-daemon
submodules: true
path: ledger-wallet-daemon
- name: Publish to WD
env:
GH_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
VERSION: ${{ github.event.inputs.version }}
run: .github/scripts/publish_to_wd.sh