2021-06-10 14:01:55 +02:00
|
|
|
name: Joplin Continuous Integration
|
2021-06-11 00:24:44 +02:00
|
|
|
on: [push, pull_request]
|
2021-06-10 14:01:55 +02:00
|
|
|
jobs:
|
2022-11-07 18:24:58 +02:00
|
|
|
pre_job:
|
2023-03-30 23:55:03 +02:00
|
|
|
if: github.repository == 'laurent22/joplin'
|
2023-09-24 16:38:32 +02:00
|
|
|
# Do not use unbuntu-latest because it causes `The operation was canceled` failures:
|
|
|
|
# https://github.com/actions/runner-images/issues/6709
|
2023-09-24 16:36:54 +02:00
|
|
|
runs-on: ubuntu-20.04
|
2022-11-07 18:24:58 +02:00
|
|
|
outputs:
|
|
|
|
should_skip: ${{ steps.skip_check.outputs.should_skip }}
|
|
|
|
steps:
|
|
|
|
- id: skip_check
|
|
|
|
uses: fkirc/skip-duplicate-actions@v5
|
2022-11-07 19:56:45 +02:00
|
|
|
with:
|
|
|
|
concurrent_skipping: 'same_content_newer'
|
2022-11-07 18:24:58 +02:00
|
|
|
|
2021-06-10 14:01:55 +02:00
|
|
|
Main:
|
2022-11-07 18:24:58 +02:00
|
|
|
needs: pre_job
|
2022-12-16 14:14:02 +02:00
|
|
|
# We always process server or desktop release tags, because they also publish the release
|
2023-03-30 23:57:58 +02:00
|
|
|
if: github.repository == 'laurent22/joplin' && (needs.pre_job.outputs.should_skip != 'true' || startsWith(github.ref, 'refs/tags/server-v') || startsWith(github.ref, 'refs/tags/v'))
|
2021-06-10 14:01:55 +02:00
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2023-09-24 16:38:32 +02:00
|
|
|
# Do not use unbuntu-latest because it causes `The operation was canceled` failures:
|
|
|
|
# https://github.com/actions/runner-images/issues/6709
|
2023-09-24 16:36:54 +02:00
|
|
|
os: [macos-latest, ubuntu-20.04, windows-2019]
|
2021-06-10 14:01:55 +02:00
|
|
|
steps:
|
|
|
|
|
2022-11-05 02:14:43 +02:00
|
|
|
# Trying to fix random networking issues on Windows
|
|
|
|
# https://github.com/actions/runner-images/issues/1187#issuecomment-686735760
|
|
|
|
- name: Disable TCP/UDP offload on Windows
|
|
|
|
if: runner.os == 'Windows'
|
|
|
|
run: Disable-NetAdapterChecksumOffload -Name * -TcpIPv4 -UdpIPv4 -TcpIPv6 -UdpIPv6
|
|
|
|
|
2022-11-05 12:16:23 +02:00
|
|
|
- name: Disable TCP/UDP offload on Linux
|
|
|
|
if: runner.os == 'Linux'
|
|
|
|
run: sudo ethtool -K eth0 tx off rx off
|
|
|
|
|
|
|
|
- name: Disable TCP/UDP offload on macOS
|
|
|
|
if: runner.os == 'macOS'
|
|
|
|
run: |
|
|
|
|
sudo sysctl -w net.link.generic.system.hwcksum_tx=0
|
|
|
|
sudo sysctl -w net.link.generic.system.hwcksum_rx=0
|
|
|
|
|
2021-06-10 14:01:55 +02:00
|
|
|
# Silence apt-get update errors (for example when a module doesn't
|
|
|
|
# exist) since otherwise it will make the whole build fails, even though
|
|
|
|
# it might work without update. libsecret-1-dev is required for keytar -
|
|
|
|
# https://github.com/atom/node-keytar
|
2021-06-11 18:24:59 +02:00
|
|
|
|
2021-06-10 14:01:55 +02:00
|
|
|
- name: Install Linux dependencies
|
|
|
|
if: runner.os == 'Linux'
|
|
|
|
run: |
|
|
|
|
sudo apt-get update || true
|
|
|
|
sudo apt-get install -y gettext
|
|
|
|
sudo apt-get install -y libsecret-1-dev
|
2021-11-08 19:10:33 +02:00
|
|
|
sudo apt-get install -y translate-toolkit
|
2023-06-01 10:44:07 +02:00
|
|
|
sudo apt-get install -y rsync
|
2023-10-13 16:32:10 +02:00
|
|
|
# Provides a virtual display on Linux. Used for Playwright integration
|
|
|
|
# testing.
|
|
|
|
sudo apt-get install -y xvfb
|
2021-11-08 19:10:33 +02:00
|
|
|
|
2021-06-11 18:24:59 +02:00
|
|
|
- name: Install Docker Engine
|
2021-11-30 17:37:07 +02:00
|
|
|
# if: runner.os == 'Linux' && startsWith(github.ref, 'refs/tags/server-v')
|
|
|
|
if: runner.os == 'Linux'
|
2021-06-11 18:24:59 +02:00
|
|
|
run: |
|
|
|
|
sudo apt-get install -y apt-transport-https
|
|
|
|
sudo apt-get install -y ca-certificates
|
|
|
|
sudo apt-get install -y curl
|
|
|
|
sudo apt-get install -y gnupg
|
|
|
|
sudo apt-get install -y lsb-release
|
|
|
|
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
|
|
|
|
echo \
|
|
|
|
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
|
|
|
|
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
|
|
|
sudo apt-get update || true
|
|
|
|
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
|
|
|
|
|
2021-06-10 14:01:55 +02:00
|
|
|
- uses: actions/checkout@v2
|
|
|
|
- uses: olegtarasov/get-tag@v2.1
|
|
|
|
- uses: actions/setup-node@v2
|
|
|
|
with:
|
2023-04-23 23:58:43 +02:00
|
|
|
# We need to pin the version to 18.15, because 18.16+ fails with this error:
|
|
|
|
# https://github.com/facebook/react-native/issues/36440
|
|
|
|
node-version: '18.15.0'
|
2023-08-05 17:57:17 +02:00
|
|
|
cache: 'yarn'
|
2021-12-20 17:08:43 +02:00
|
|
|
|
|
|
|
- name: Install Yarn
|
|
|
|
run: |
|
|
|
|
# https://yarnpkg.com/getting-started/install
|
|
|
|
corepack enable
|
2021-06-11 18:24:59 +02:00
|
|
|
|
2021-06-12 08:52:09 +02:00
|
|
|
# Login to Docker only if we're on a server release tag. If we run this on
|
|
|
|
# a pull request it will fail because the PR doesn't have access to
|
|
|
|
# secrets
|
2023-12-06 12:16:15 +02:00
|
|
|
- uses: docker/login-action@v3
|
2021-06-12 08:52:09 +02:00
|
|
|
if: runner.os == 'Linux' && startsWith(github.ref, 'refs/tags/server-v')
|
2021-06-11 18:24:59 +02:00
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
2021-06-10 14:01:55 +02:00
|
|
|
|
2023-11-05 15:33:38 +02:00
|
|
|
# macos-latest ships with Python 3.12 by default, but this removes a
|
|
|
|
# utility that's used by electron-builder (distutils) so we need to pin
|
|
|
|
# Python to an earlier version.
|
|
|
|
# Fixes error `ModuleNotFoundError: No module named 'distutils'`
|
|
|
|
# Ref: https://github.com/nodejs/node-gyp/issues/2869
|
|
|
|
- uses: actions/setup-python@v4
|
|
|
|
with:
|
|
|
|
python-version: '3.11'
|
|
|
|
|
2021-07-09 18:50:12 +02:00
|
|
|
- name: Run tests, build and publish Linux and macOS apps
|
|
|
|
if: runner.os == 'Linux' || runner.os == 'macOs'
|
2021-06-10 14:01:55 +02:00
|
|
|
env:
|
|
|
|
APPLE_ASC_PROVIDER: ${{ secrets.APPLE_ASC_PROVIDER }}
|
|
|
|
APPLE_ID: ${{ secrets.APPLE_ID }}
|
|
|
|
APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
|
2023-04-06 14:02:45 +02:00
|
|
|
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
|
2021-07-09 18:50:12 +02:00
|
|
|
CSC_KEY_PASSWORD: ${{ secrets.APPLE_CSC_KEY_PASSWORD }}
|
|
|
|
CSC_LINK: ${{ secrets.APPLE_CSC_LINK }}
|
2021-06-10 14:01:55 +02:00
|
|
|
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
2021-06-10 17:43:09 +02:00
|
|
|
IS_CONTINUOUS_INTEGRATION: 1
|
2022-01-01 16:24:56 +02:00
|
|
|
BUILD_SEQUENCIAL: 1
|
2023-03-19 11:07:19 +02:00
|
|
|
SERVER_REPOSITORY: joplin/server
|
2022-10-11 11:42:13 +02:00
|
|
|
SERVER_TAG_PREFIX: server
|
2021-06-10 14:01:55 +02:00
|
|
|
run: |
|
|
|
|
"${GITHUB_WORKSPACE}/.github/scripts/run_ci.sh"
|
2021-07-09 18:50:12 +02:00
|
|
|
|
|
|
|
- name: Build and publish Windows app
|
|
|
|
if: runner.os == 'Windows' && startsWith(github.ref, 'refs/tags/v')
|
|
|
|
env:
|
|
|
|
CSC_KEY_PASSWORD: ${{ secrets.WINDOWS_CSC_KEY_PASSWORD }}
|
|
|
|
CSC_LINK: ${{ secrets.WINDOWS_CSC_LINK }}
|
|
|
|
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
|
|
|
IS_CONTINUOUS_INTEGRATION: 1
|
2022-01-01 16:24:56 +02:00
|
|
|
BUILD_SEQUENCIAL: 1
|
2022-01-17 16:09:02 +02:00
|
|
|
# To ensure that the operations stop on failure, all commands
|
|
|
|
# should be on one line with "&&" in between.
|
2021-07-09 18:50:12 +02:00
|
|
|
run: |
|
2022-01-17 16:09:02 +02:00
|
|
|
yarn install && cd packages/app-desktop && yarn run dist
|
|
|
|
|
|
|
|
# Build and package the Windows app, without publishing it, just to
|
|
|
|
# verify that the build process hasn't been broken.
|
|
|
|
- name: Build Windows app (no publishing)
|
|
|
|
if: runner.os == 'Windows' && !startsWith(github.ref, 'refs/tags/v')
|
|
|
|
env:
|
|
|
|
IS_CONTINUOUS_INTEGRATION: 1
|
|
|
|
BUILD_SEQUENCIAL: 1
|
2023-03-19 11:07:19 +02:00
|
|
|
SERVER_REPOSITORY: joplin/server
|
2022-02-23 11:02:13 +02:00
|
|
|
SERVER_TAG_PREFIX: server
|
2022-01-17 16:09:02 +02:00
|
|
|
run: |
|
|
|
|
yarn install && cd packages/app-desktop && yarn run dist --publish=never
|
2021-12-20 17:08:43 +02:00
|
|
|
|
|
|
|
ServerDockerImage:
|
2022-11-07 18:24:58 +02:00
|
|
|
needs: pre_job
|
2023-03-30 23:57:58 +02:00
|
|
|
if: github.repository == 'laurent22/joplin' && needs.pre_job.outputs.should_skip != 'true'
|
2021-12-20 17:08:43 +02:00
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2023-09-24 16:38:32 +02:00
|
|
|
# Do not use unbuntu-latest because it causes `The operation was canceled` failures:
|
|
|
|
# https://github.com/actions/runner-images/issues/6709
|
2023-09-24 16:36:54 +02:00
|
|
|
os: [ubuntu-20.04]
|
2021-12-20 17:08:43 +02:00
|
|
|
steps:
|
|
|
|
|
|
|
|
- name: Install Docker Engine
|
|
|
|
run: |
|
|
|
|
sudo apt-get install -y apt-transport-https
|
|
|
|
sudo apt-get install -y ca-certificates
|
|
|
|
sudo apt-get install -y curl
|
|
|
|
sudo apt-get install -y gnupg
|
|
|
|
sudo apt-get install -y lsb-release
|
|
|
|
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
|
|
|
|
echo \
|
|
|
|
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
|
|
|
|
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
|
|
|
sudo apt-get update || true
|
|
|
|
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
|
|
|
|
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- uses: actions/setup-node@v2
|
|
|
|
with:
|
2022-11-03 22:18:11 +02:00
|
|
|
node-version: '18'
|
2023-08-05 17:57:17 +02:00
|
|
|
cache: 'yarn'
|
2021-12-20 17:08:43 +02:00
|
|
|
|
|
|
|
- name: Install Yarn
|
|
|
|
run: |
|
|
|
|
# https://yarnpkg.com/getting-started/install
|
|
|
|
corepack enable
|
|
|
|
|
|
|
|
- name: Build Docker Image
|
2022-01-01 16:24:56 +02:00
|
|
|
env:
|
|
|
|
BUILD_SEQUENCIAL: 1
|
2021-12-20 17:08:43 +02:00
|
|
|
run: |
|
|
|
|
yarn install
|
2023-03-19 11:07:19 +02:00
|
|
|
yarn run buildServerDocker --tag-name server-v0.0.0 --repository joplin/server
|
2022-11-05 18:57:09 +02:00
|
|
|
|
|
|
|
# Basic test to ensure that the created build is valid. It should exit with
|
|
|
|
# code 0 if it works.
|
2023-03-19 11:07:19 +02:00
|
|
|
docker run joplin/server:0.0.0-beta node dist/app.js migrate list
|
2023-06-19 18:06:22 +02:00
|
|
|
|
|
|
|
- name: Check HTTP request
|
|
|
|
run: |
|
|
|
|
# Need to pass environment variables:
|
|
|
|
docker run -p 22300:22300 joplin/server:0.0.0-beta node dist/app.js --env dev &
|
|
|
|
|
|
|
|
# Wait for server to start
|
2023-07-18 19:43:50 +02:00
|
|
|
sleep 30
|
2023-06-19 18:06:22 +02:00
|
|
|
|
|
|
|
# Check if status code is correct
|
|
|
|
# if the actual_status DOES NOT include the expected_status
|
|
|
|
# it exits the process with code 1
|
|
|
|
|
|
|
|
expected_status="HTTP/1.1 200 OK"
|
|
|
|
actual_status=$(curl -I -X GET http://localhost:22300/api/ping | head -n 1)
|
|
|
|
if [[ ! "$actual_status" =~ "$expected_status" ]]; then
|
|
|
|
echo 'Failed while checking the status code after request to /api/ping'
|
|
|
|
echo 'expected: ' $expected_status
|
|
|
|
echo 'actual: ' $actual_status
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check if the body response is correct
|
|
|
|
# if the actual_body is different of expected_body exit with code 1
|
|
|
|
expected_body='{"status":"ok","message":"Joplin Server is running"}'
|
|
|
|
actual_body=$(curl http://localhost:22300/api/ping)
|
|
|
|
|
|
|
|
if [[ "$actual_body" != "$expected_body" ]]; then
|
|
|
|
echo 'Failed while checking the body response after request to /api/ping'
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|