Skip to content

Commit 0639526

Browse files
Handle hex parsing in Color with format support (#2964)
* Handle hex parsing in Color with format support * Rewrite to remove allocations * Fix formatting * Create zero-allocation version * Use primed OS independent LFS caching * Use a normalized cache key so Windows uses it. * Fix LFS caching * Remove bad task * Try to get Windows to use the cache * Try again.
1 parent 0843217 commit 0639526

File tree

8 files changed

+546
-199
lines changed

8 files changed

+546
-199
lines changed

.github/workflows/build-and-test.yml

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,54 @@ on:
1212
- main
1313
- release/*
1414
types: [ labeled, opened, synchronize, reopened ]
15+
1516
jobs:
17+
# Prime a single LFS cache and expose the exact key for the matrix
18+
WarmLFS:
19+
runs-on: ubuntu-latest
20+
outputs:
21+
lfs_key: ${{ steps.expose-key.outputs.lfs_key }}
22+
steps:
23+
- name: Git Config
24+
shell: bash
25+
run: |
26+
git config --global core.autocrlf false
27+
git config --global core.longpaths true
28+
29+
- name: Git Checkout
30+
uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 0
33+
submodules: recursive
34+
35+
# Deterministic list of LFS object IDs, then compute a portable key:
36+
# - `git lfs ls-files -l` lists all tracked LFS objects with their SHA-256
37+
# - `awk '{print $1}'` extracts just the SHA field
38+
# - `sort` sorts in byte order (hex hashes sort the same everywhere)
39+
# This ensures the file content is identical regardless of OS or locale
40+
- name: Git Create LFS id list
41+
shell: bash
42+
run: git lfs ls-files -l | awk '{print $1}' | sort > .lfs-assets-id
43+
44+
- name: Git Expose LFS cache key
45+
id: expose-key
46+
shell: bash
47+
env:
48+
LFS_KEY: lfs-${{ hashFiles('.lfs-assets-id') }}-v1
49+
run: echo "lfs_key=$LFS_KEY" >> "$GITHUB_OUTPUT"
50+
51+
- name: Git Setup LFS Cache
52+
uses: actions/cache@v4
53+
with:
54+
path: .git/lfs
55+
key: ${{ steps.expose-key.outputs.lfs_key }}
56+
57+
- name: Git Pull LFS
58+
shell: bash
59+
run: git lfs pull
60+
1661
Build:
62+
needs: WarmLFS
1763
strategy:
1864
matrix:
1965
isARM:
@@ -69,14 +115,14 @@ jobs:
69115
options:
70116
os: buildjet-4vcpu-ubuntu-2204-arm
71117

72-
runs-on: ${{matrix.options.os}}
118+
runs-on: ${{ matrix.options.os }}
73119

74120
steps:
75121
- name: Install libgdi+, which is required for tests running on ubuntu
76122
if: ${{ contains(matrix.options.os, 'ubuntu') }}
77123
run: |
78-
sudo apt-get update
79-
sudo apt-get -y install libgdiplus libgif-dev libglib2.0-dev libcairo2-dev libtiff-dev libexif-dev
124+
sudo apt-get update
125+
sudo apt-get -y install libgdiplus libgif-dev libglib2.0-dev libcairo2-dev libtiff-dev libexif-dev
80126
81127
- name: Git Config
82128
shell: bash
@@ -90,18 +136,15 @@ jobs:
90136
fetch-depth: 0
91137
submodules: recursive
92138

93-
# See https://github.com/actions/checkout/issues/165#issuecomment-657673315
94-
- name: Git Create LFS FileList
95-
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
96-
139+
# Use the warmed key from WarmLFS. Do not recompute or recreate .lfs-assets-id here.
97140
- name: Git Setup LFS Cache
98141
uses: actions/cache@v4
99-
id: lfs-cache
100142
with:
101143
path: .git/lfs
102-
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}-v1
144+
key: ${{ needs.WarmLFS.outputs.lfs_key }}
103145

104146
- name: Git Pull LFS
147+
shell: bash
105148
run: git lfs pull
106149

107150
- name: NuGet Install
@@ -168,11 +211,8 @@ jobs:
168211

169212
Publish:
170213
needs: [Build]
171-
172214
runs-on: ubuntu-latest
173-
174215
if: (github.event_name == 'push')
175-
176216
steps:
177217
- name: Git Config
178218
shell: bash
@@ -213,4 +253,3 @@ jobs:
213253
run: |
214254
dotnet nuget push .\artifacts\*.nupkg -k ${{secrets.NUGET_TOKEN}} -s https://api.nuget.org/v3/index.json --skip-duplicate
215255
dotnet nuget push .\artifacts\*.snupkg -k ${{secrets.NUGET_TOKEN}} -s https://api.nuget.org/v3/index.json --skip-duplicate
216-

.github/workflows/code-coverage.yml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
schedule:
55
# 2AM every Tuesday/Thursday
66
- cron: "0 2 * * 2,4"
7+
78
jobs:
89
Build:
910
strategy:
@@ -14,15 +15,14 @@ jobs:
1415
runtime: -x64
1516
codecov: true
1617

17-
runs-on: ${{matrix.options.os}}
18+
runs-on: ${{ matrix.options.os }}
1819

1920
steps:
20-
2121
- name: Install libgdi+, which is required for tests running on ubuntu
2222
if: ${{ contains(matrix.options.os, 'ubuntu') }}
2323
run: |
24-
sudo apt-get update
25-
sudo apt-get -y install libgdiplus libgif-dev libglib2.0-dev libcairo2-dev libtiff-dev libexif-dev
24+
sudo apt-get update
25+
sudo apt-get -y install libgdiplus libgif-dev libglib2.0-dev libcairo2-dev libtiff-dev libexif-dev
2626
2727
- name: Git Config
2828
shell: bash
@@ -36,16 +36,21 @@ jobs:
3636
fetch-depth: 0
3737
submodules: recursive
3838

39-
# See https://github.com/actions/checkout/issues/165#issuecomment-657673315
40-
- name: Git Create LFS FileList
41-
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
39+
# Deterministic list of LFS object IDs, then compute a portable key:
40+
# - `git lfs ls-files -l` lists all tracked LFS objects with their SHA-256
41+
# - `awk '{print $1}'` extracts just the SHA field
42+
# - `sort` sorts in byte order (hex hashes sort the same everywhere)
43+
# This ensures the file content is identical regardless of OS or locale
44+
- name: Git Create LFS id list
45+
shell: bash
46+
run: git lfs ls-files -l | awk '{print $1}' | sort > .lfs-assets-id
4247

4348
- name: Git Setup LFS Cache
4449
uses: actions/cache@v4
4550
id: lfs-cache
4651
with:
4752
path: .git/lfs
48-
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}-v1
53+
key: lfs-${{ hashFiles('.lfs-assets-id') }}-v1
4954

5055
- name: Git Pull LFS
5156
run: git lfs pull
@@ -69,13 +74,13 @@ jobs:
6974
7075
- name: DotNet Build
7176
shell: pwsh
72-
run: ./ci-build.ps1 "${{matrix.options.framework}}"
77+
run: ./ci-build.ps1 "${{ matrix.options.framework }}"
7378
env:
7479
SIXLABORS_TESTING: True
7580

7681
- name: DotNet Test
7782
shell: pwsh
78-
run: ./ci-test.ps1 "${{matrix.options.os}}" "${{matrix.options.framework}}" "${{matrix.options.runtime}}" "${{matrix.options.codecov}}"
83+
run: ./ci-test.ps1 "${{ matrix.options.os }}" "${{ matrix.options.framework }}" "${{ matrix.options.runtime }}" "${{ matrix.options.codecov }}"
7984
env:
8085
SIXLABORS_TESTING: True
8186
XUNIT_PATH: .\tests\ImageSharp.Tests # Required for xunit

0 commit comments

Comments
 (0)