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: Resolves #123: Add FlyCI Wingman #1

Open
wants to merge 11 commits into
base: dev
Choose a base branch
from
4 changes: 2 additions & 2 deletions .github/workflows/build-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on: [push, pull_request]

jobs:
pre_job:
if: github.repository == 'laurent22/joplin'
if: github.repository == 'kgantchev/joplin'
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
Expand All @@ -18,7 +18,7 @@ jobs:

AssembleRelease:
needs: pre_job
if: github.repository == 'laurent22/joplin' && needs.pre_job.outputs.should_skip != 'true'
if: github.repository == 'kgantchev/joplin' && needs.pre_job.outputs.should_skip != 'true'
runs-on: ubuntu-latest
steps:
- name: Install Linux dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-macos-m1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build macOS M1
on: [push, pull_request]
jobs:
pre_job:
if: github.repository == 'laurent22/joplin'
if: github.repository == 'kgantchev/joplin'
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
Expand All @@ -15,7 +15,7 @@ jobs:
Main:
needs: pre_job
# We always process desktop release tags, because they also publish the release
if: github.repository == 'laurent22/joplin' && (needs.pre_job.outputs.should_skip != 'true' || startsWith(github.ref, 'refs/tags/v'))
if: github.repository == 'kgantchev/joplin' && (needs.pre_job.outputs.should_skip != 'true' || startsWith(github.ref, 'refs/tags/v'))
runs-on: macos-latest
steps:

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cla.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
CLAAssistant:
if: github.repository == 'laurent22/joplin'
if: github.repository == 'kgantchev/joplin'
runs-on: ubuntu-latest
steps:
- name: "CLA Assistant"
Expand Down
133 changes: 39 additions & 94 deletions .github/workflows/github-actions-main.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
name: Joplin Continuous Integration

on: [push, pull_request]

permissions:
contents: read
pages: write
id-token: write

jobs:
pre_job:
if: github.repository == 'laurent22/joplin'
# Do not use unbuntu-latest because it causes `The operation was canceled` failures:
# https://github.com/actions/runner-images/issues/6709
runs-on: ubuntu-20.04
if: github.repository == 'kgantchev/joplin'
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
Expand All @@ -16,18 +21,15 @@ jobs:

Main:
needs: pre_job
# We always process server or desktop release tags, because they also publish the release
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'))
if: github.repository == 'kgantchev/joplin' &&
(needs.pre_job.outputs.should_skip != 'true' ||
startsWith(github.ref, 'refs/tags/server-v') ||
startsWith(github.ref, 'refs/tags/v'))
runs-on: ${{ matrix.os }}
strategy:
matrix:
# Do not use unbuntu-latest because it causes `The operation was canceled` failures:
# https://github.com/actions/runner-images/issues/6709
os: [macos-12, ubuntu-20.04, windows-2019]
os: [macos-latest, ubuntu-latest, windows-2019]
steps:

# 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
Expand All @@ -42,79 +44,49 @@ jobs:
sudo sysctl -w net.link.generic.system.hwcksum_tx=0
sudo sysctl -w net.link.generic.system.hwcksum_rx=0

# 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

- 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
sudo apt-get install -y translate-toolkit
sudo apt-get install -y rsync
# Provides a virtual display on Linux. Used for Playwright integration
# testing.
sudo apt-get install -y xvfb

- name: Install macOs dependencies
sudo apt-get install -y gettext libsecret-1-dev translate-toolkit rsync xvfb

- name: Install macOS dependencies
if: runner.os == 'macOS'
run: |
# Required for building the canvas package
brew install pango
run: brew install pango

- name: Install Docker Engine
# if: runner.os == 'Linux' && startsWith(github.ref, 'refs/tags/server-v')
if: runner.os == 'Linux'
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
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg 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
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@v4

- uses: olegtarasov/[email protected]

- uses: actions/setup-node@v4
with:
# 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'
cache: 'yarn'

- name: Install Yarn
run: |
# https://yarnpkg.com/getting-started/install
corepack enable

# 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
run: corepack enable

- uses: docker/login-action@v3
if: runner.os == 'Linux' && startsWith(github.ref, 'refs/tags/server-v')
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

# 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@v5
with:
python-version: '3.11'

- name: Run tests, build and publish Linux and macOS apps
if: runner.os == 'Linux' || runner.os == 'macOs'
if: runner.os == 'Linux' || runner.os == 'macOS'
env:
APPLE_ASC_PROVIDER: ${{ secrets.APPLE_ASC_PROVIDER }}
APPLE_ID: ${{ secrets.APPLE_ID }}
Expand All @@ -128,8 +100,7 @@ jobs:
SERVER_REPOSITORY: joplin/server
SERVER_TAG_PREFIX: server
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
run: |
"${GITHUB_WORKSPACE}/.github/scripts/run_ci.sh"
run: "${GITHUB_WORKSPACE}/.github/scripts/run_ci.sh"

- name: Build and publish Windows app
if: runner.os == 'Windows' && startsWith(github.ref, 'refs/tags/v')
Expand All @@ -139,13 +110,9 @@ jobs:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
IS_CONTINUOUS_INTEGRATION: 1
BUILD_SEQUENCIAL: 1
# To ensure that the operations stop on failure, all commands
# should be on one line with "&&" in between.
run: |
yarn install && cd packages/app-desktop && yarn 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:
Expand All @@ -156,28 +123,20 @@ jobs:
run: |
yarn install && cd packages/app-desktop && yarn dist --publish=never

- name: Fix my build
uses: fly-ci/wingman-action@v1
if: failure()

ServerDockerImage:
needs: pre_job
if: github.repository == 'laurent22/joplin' && needs.pre_job.outputs.should_skip != 'true'
runs-on: ${{ matrix.os }}
strategy:
matrix:
# Do not use unbuntu-latest because it causes `The operation was canceled` failures:
# https://github.com/actions/runner-images/issues/6709
os: [ubuntu-20.04]
if: github.repository == 'kgantchev/joplin' && needs.pre_job.outputs.should_skip != 'true'
runs-on: ubuntu-latest
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
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg 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
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

Expand All @@ -189,33 +148,20 @@ jobs:
cache: 'yarn'

- name: Install Yarn
run: |
# https://yarnpkg.com/getting-started/install
corepack enable
run: corepack enable

- name: Build Docker Image
env:
BUILD_SEQUENCIAL: 1
run: |
yarn install
yarn buildServerDocker --tag-name server-v0.0.0 --repository joplin/server

# Basic test to ensure that the created build is valid. It should exit with
# code 0 if it works.
docker run joplin/server:0.0.0-beta node dist/app.js migrate list

- 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
sleep 30

# 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
Expand All @@ -224,14 +170,13 @@ jobs:
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

- name: Fix my build
uses: fly-ci/wingman-action@v1
if: failure()
12 changes: 12 additions & 0 deletions packages/app-desktop/integration-tests/main.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,5 +189,17 @@ test.describe('main', () => {

await electronApp.close();
});

test('should create and display tags correctly', async ({ mainWindow }) => {
const mainScreen = new MainScreen(mainWindow);
const editor = await mainScreen.createNewNote('Test Note with Tag');
await editor.focusCodeMirrorEditor();
await mainWindow.keyboard.press('Enter');
await mainWindow.keyboard.type('#tag1 #tag2');
await mainScreen.saveNote();
const noteListItem = mainScreen.noteListContainer.getByText('Test Note with Tag');
await expect(noteListItem).toBeVisible();
await expect(noteListItem.locator('.tag')).toHaveText('#tag1 #tag2');
});
});

Loading