Skip to content

Commit 52a844f

Browse files
committed
Merge branch 'issue-1544-textscaling' of github.com:asturur/node-canvas into issue-1544-textscaling
2 parents 0a98825 + 573dfab commit 52a844f

29 files changed

+691
-104
lines changed

.github/workflows/ci.yaml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Test
2+
on:
3+
push:
4+
paths-ignore:
5+
- ".github/workflows/prebuild.yaml"
6+
pull_request:
7+
paths-ignore:
8+
- ".github/workflows/prebuild.yaml"
9+
10+
11+
jobs:
12+
Linux:
13+
name: Test on Linux
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
node: [10, 12, 14]
18+
steps:
19+
- uses: actions/setup-node@v1
20+
with:
21+
node-version: ${{ matrix.node }}
22+
- uses: actions/checkout@v2
23+
- name: Install Dependencies
24+
run: |
25+
sudo apt update
26+
sudo apt install -y libcairo2-dev libjpeg-dev libpango1.0-dev libgif-dev librsvg2-dev
27+
- name: Install
28+
run: npm install --build-from-source
29+
- name: Test
30+
run: npm test
31+
32+
Windows:
33+
name: Test on Windows
34+
runs-on: windows-latest
35+
strategy:
36+
matrix:
37+
node: [10, 12, 14]
38+
steps:
39+
- uses: actions/setup-node@v1
40+
with:
41+
node-version: ${{ matrix.node }}
42+
- uses: actions/checkout@v2
43+
- name: Install Dependencies
44+
run: |
45+
Invoke-WebRequest "http://ftp.gnome.org/pub/GNOME/binaries/win64/gtk+/2.22/gtk+-bundle_2.22.1-20101229_win64.zip" -OutFile "gtk.zip"
46+
Expand-Archive gtk.zip -DestinationPath "C:\GTK"
47+
Invoke-WebRequest "https://downloads.sourceforge.net/project/libjpeg-turbo/2.0.4/libjpeg-turbo-2.0.4-vc64.exe" -OutFile "libjpeg.exe" -UserAgent NativeHost
48+
.\libjpeg.exe /S
49+
- name: Install
50+
run: npm install --build-from-source
51+
- name: Test
52+
run: npm test
53+
54+
macOS:
55+
name: Test on macOS
56+
runs-on: macos-latest
57+
strategy:
58+
matrix:
59+
node: [10, 12, 14]
60+
steps:
61+
- uses: actions/setup-node@v1
62+
with:
63+
node-version: ${{ matrix.node }}
64+
- uses: actions/checkout@v2
65+
- name: Install Dependencies
66+
run: |
67+
brew update
68+
brew install pkg-config cairo pango libpng jpeg giflib librsvg
69+
- name: Install
70+
run: npm install --build-from-source
71+
- name: Test
72+
run: npm test
73+
74+
Lint:
75+
name: Lint
76+
runs-on: ubuntu-latest
77+
steps:
78+
- uses: actions/setup-node@v1
79+
with:
80+
node-version: 12
81+
- uses: actions/checkout@v2
82+
- name: Install
83+
run: npm install --ignore-scripts
84+
- name: Lint
85+
run: npm run lint
86+
- name: Lint Types
87+
run: npm run dtslint

.github/workflows/prebuild.yaml

Lines changed: 238 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
1+
# Triggering prebuilds:
2+
# 1. Create a draft release manually using the GitHub UI.
3+
# 2. Set the `jobs.*.strategy.matrix.node` arrays to the set of Node.js versions
4+
# to build for.
5+
# 3. Set the `jobs.*.strategy.matrix.canvas_tag` arrays to the set of Canvas
6+
# tags to build. (Usually this is a single tag, but can be an array when a
7+
# new version of Node.js is released and older versions of Canvas need to be
8+
# built.)
9+
# 4. Commit and push this file to master.
10+
# 5. Once the builds succeed, promote the draft release to a full release.
11+
12+
name: Make Prebuilds
13+
on:
14+
push:
15+
branches:
16+
- 'master'
17+
paths:
18+
- '.github/workflows/prebuild.yaml'
19+
# UPLOAD_TO can be specified to upload the release assets under a different tag
20+
# name (e.g. for testing). If omitted, the assets are published under the same
21+
# release tag as the canvas version being built.
22+
# env:
23+
# UPLOAD_TO: "v0.0.1"
24+
25+
jobs:
26+
Linux:
27+
strategy:
28+
matrix:
29+
node: [8, 9, 10, 11, 12, 13, 14]
30+
canvas_tag: [] # e.g. "v2.6.1"
31+
name: ${{ matrix.canvas_tag}}, Node.js ${{ matrix.node }}, Linux
32+
runs-on: ubuntu-latest
33+
container:
34+
image: chearon/canvas-prebuilt:7
35+
env:
36+
CANVAS_VERSION_TO_BUILD: ${{ matrix.canvas_tag }}
37+
steps:
38+
- uses: actions/checkout@v2
39+
with:
40+
ref: ${{ matrix.canvas_tag }}
41+
42+
- uses: actions/setup-node@v1
43+
with:
44+
node-version: ${{ matrix.node }}
45+
46+
- name: Build
47+
run: |
48+
npm install -g node-gyp
49+
npm install --ignore-scripts
50+
. prebuild/Linux/preinstall.sh
51+
cp prebuild/Linux/binding.gyp binding.gyp
52+
node-gyp rebuild -j 2
53+
. prebuild/Linux/bundle.sh
54+
55+
- name: Test binary
56+
run: |
57+
cd /root/harfbuzz-* && make uninstall
58+
cd /root/cairo-* && make uninstall
59+
cd /root/pango-* && make uninstall
60+
cd /root/libpng-* && make uninstall
61+
cd /root/libjpeg-* && make uninstall
62+
cd /root/giflib-* && make uninstall
63+
cd $GITHUB_WORKSPACE && npm test
64+
65+
- name: Make bundle
66+
id: make_bundle
67+
run: . prebuild/tarball.sh
68+
69+
- name: Upload
70+
uses: actions/github-script@0.9.0
71+
with:
72+
script: |
73+
const fs = require("fs");
74+
const assetName = "${{ steps.make_bundle.outputs.asset_name }}";
75+
const tagName = process.env.UPLOAD_TO || process.env.CANVAS_VERSION_TO_BUILD;
76+
const [owner, repo] = process.env.GITHUB_REPOSITORY.split("/");
77+
78+
const releases = await github.repos.listReleases({owner, repo});
79+
const release = releases.data.find(r => r.tag_name === tagName);
80+
if (!release)
81+
throw new Error(`Tag ${tagName} not found. Did you make the GitHub release?`);
82+
83+
const oldAsset = release.assets.find(a => a.name === assetName);
84+
if (oldAsset)
85+
await github.repos.deleteReleaseAsset({owner, repo, asset_id: oldAsset.id});
86+
87+
// (This is equivalent to actions/upload-release-asset. We're
88+
// already in a script, so might as well do it here.)
89+
const r = await github.repos.uploadReleaseAsset({
90+
url: release.upload_url,
91+
headers: {
92+
"content-type": "application/x-gzip",
93+
"content-length": `${fs.statSync(assetName).size}`
94+
},
95+
name: assetName,
96+
data: fs.readFileSync(assetName)
97+
});
98+
99+
macOS:
100+
strategy:
101+
matrix:
102+
node: [8, 9, 10, 11, 12, 13, 14]
103+
canvas_tag: [] # e.g. "v2.6.1"
104+
name: ${{ matrix.canvas_tag}}, Node.js ${{ matrix.node }}, macOS
105+
runs-on: macos-latest
106+
env:
107+
CANVAS_VERSION_TO_BUILD: ${{ matrix.canvas_tag }}
108+
steps:
109+
- uses: actions/checkout@v2
110+
with:
111+
ref: ${{ matrix.canvas_tag }}
112+
113+
- uses: actions/setup-node@v1
114+
with:
115+
node-version: ${{ matrix.node }}
116+
117+
- name: Build
118+
run: |
119+
npm install -g node-gyp
120+
npm install --ignore-scripts
121+
. prebuild/macOS/preinstall.sh
122+
cp prebuild/macOS/binding.gyp binding.gyp
123+
node-gyp rebuild -j 2
124+
. prebuild/macOS/bundle.sh
125+
126+
- name: Test binary
127+
run: |
128+
brew uninstall --force cairo pango librsvg giflib harfbuzz
129+
npm test
130+
131+
- name: Make bundle
132+
id: make_bundle
133+
run: . prebuild/tarball.sh
134+
135+
- name: Upload
136+
uses: actions/github-script@0.9.0
137+
with:
138+
script: |
139+
const fs = require("fs");
140+
const assetName = "${{ steps.make_bundle.outputs.asset_name }}";
141+
const tagName = process.env.UPLOAD_TO || process.env.CANVAS_VERSION_TO_BUILD;
142+
const [owner, repo] = process.env.GITHUB_REPOSITORY.split("/");
143+
144+
const releases = await github.repos.listReleases({owner, repo});
145+
const release = releases.data.find(r => r.tag_name === tagName);
146+
if (!release)
147+
throw new Error(`Tag ${tagName} not found. Did you make the GitHub release?`);
148+
149+
const oldAsset = release.assets.find(a => a.name === assetName);
150+
if (oldAsset)
151+
await github.repos.deleteReleaseAsset({owner, repo, asset_id: oldAsset.id});
152+
153+
// (This is equivalent to actions/upload-release-asset. We're
154+
// already in a script, so might as well do it here.)
155+
const r = await github.repos.uploadReleaseAsset({
156+
url: release.upload_url,
157+
headers: {
158+
"content-type": "application/x-gzip",
159+
"content-length": `${fs.statSync(assetName).size}`
160+
},
161+
name: assetName,
162+
data: fs.readFileSync(assetName)
163+
});
164+
165+
Win:
166+
strategy:
167+
matrix:
168+
node: [8, 9, 10, 11, 12, 13, 14]
169+
canvas_tag: [] # e.g. "v2.6.1"
170+
name: ${{ matrix.canvas_tag}}, Node.js ${{ matrix.node }}, Windows
171+
runs-on: windows-latest
172+
env:
173+
CANVAS_VERSION_TO_BUILD: ${{ matrix.canvas_tag }}
174+
steps:
175+
# TODO drop when https://github.com/actions/virtual-environments/pull/632 lands
176+
- uses: numworks/setup-msys2@v1
177+
with:
178+
update: true
179+
path-type: inherit
180+
181+
- uses: actions/setup-node@v1
182+
with:
183+
node-version: ${{ matrix.node }}
184+
185+
- uses: actions/checkout@v2
186+
with:
187+
ref: ${{ matrix.canvas_tag }}
188+
189+
- name: Build
190+
run: |
191+
npm install -g node-gyp
192+
npm install --ignore-scripts
193+
msys2do . prebuild/Windows/preinstall.sh
194+
msys2do cp prebuild/Windows/binding.gyp binding.gyp
195+
msys2do node-gyp configure
196+
msys2do node-gyp rebuild -j 2
197+
198+
- name: Bundle
199+
run: msys2do . prebuild/Windows/bundle.sh
200+
201+
- name: Test binary
202+
# By not running in msys2, this doesn't have access to the msys2 libs
203+
run: npm test
204+
205+
- name: Make asset
206+
id: make_bundle
207+
# I can't figure out why this isn't an env var already. It shows up with `env`.
208+
run: msys2do UPLOAD_TO=${{ env.UPLOAD_TO }} CANVAS_VERSION_TO_BUILD=${{ env.CANVAS_VERSION_TO_BUILD}} . prebuild/tarball.sh
209+
210+
- name: Upload
211+
uses: actions/github-script@0.9.0
212+
with:
213+
script: |
214+
const fs = require("fs");
215+
const assetName = "${{ steps.make_bundle.outputs.asset_name }}";
216+
const tagName = process.env.UPLOAD_TO || process.env.CANVAS_VERSION_TO_BUILD;
217+
const [owner, repo] = process.env.GITHUB_REPOSITORY.split("/");
218+
219+
const releases = await github.repos.listReleases({owner, repo});
220+
const release = releases.data.find(r => r.tag_name === tagName);
221+
if (!release)
222+
throw new Error(`Tag ${tagName} not found. Did you make the GitHub release?`);
223+
224+
const oldAsset = release.assets.find(a => a.name === assetName);
225+
if (oldAsset)
226+
await github.repos.deleteReleaseAsset({owner, repo, asset_id: oldAsset.id});
227+
228+
// (This is equivalent to actions/upload-release-asset. We're
229+
// already in a script, so might as well do it here.)
230+
const r = await github.repos.uploadReleaseAsset({
231+
url: release.upload_url,
232+
headers: {
233+
"content-type": "application/x-gzip",
234+
"content-length": `${fs.statSync(assetName).size}`
235+
},
236+
name: assetName,
237+
data: fs.readFileSync(assetName)
238+
});

.travis.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,24 @@ project adheres to [Semantic Versioning](http://semver.org/).
88
(Unreleased)
99
==================
1010
### Changed
11+
* Switch CI to Github Actions. (Adds Windows and macOS builds.)
12+
* Switch prebuilds to GitHub actions in the Automattic/node-canvas repository.
13+
Previously these were in the [node-gfx/node-canvas-prebuilt](https://github.com/node-gfx/node-canvas-prebuilt)
14+
and triggered manually.
15+
* Speed up `fillStyle=` and `strokeStyle=`
1116
### Added
17+
* Export `rsvgVersion`.
1218
### Fixed
1319
* Fix BMP issues. (#1497)
1420
* Update typings to support jpg and addPage on NodeCanvasRenderingContext2D (#1509)
1521
* Fix assertion failure when using Visual Studio Code debugger to inspect Image prototype (#1534)
1622
* Tweak text baseline positioning to be as close as possible to browser canvas (#1562)
23+
* Fix signed/unsigned comparison warning introduced in 2.6.0, and function cast warnings with GCC8+
24+
* Fix to compile without JPEG support (#1593).
25+
* Fix compile errors with cairo
26+
* Fix Image#complete if the image failed to load.
27+
* Upgrade node-pre-gyp to v0.15.0 to use latest version of needle to fix error when downloading prebuilds.
28+
* Don't throw if `fillStyle` or `strokeStyle` is set to an object, but that object is not a Gradient or Pattern. (This behavior was non-standard: invalid inputs are supposed to be ignored.)
1729

1830
2.6.1
1931
==================

Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# node-canvas
22

3-
[![Build Status](https://travis-ci.org/Automattic/node-canvas.svg?branch=master)](https://travis-ci.org/Automattic/node-canvas)
3+
![Test](https://github.com/Automattic/node-canvas/workflows/Test/badge.svg)
44
[![NPM version](https://badge.fury.io/js/canvas.svg)](http://badge.fury.io/js/canvas)
55

66
node-canvas is a [Cairo](http://cairographics.org/)-backed Canvas implementation for [Node.js](http://nodejs.org).

0 commit comments

Comments
 (0)