Skip to content

Commit 06621e2

Browse files
committed
Migrate to official download action
1 parent 4cf0ec3 commit 06621e2

File tree

5 files changed

+214
-32
lines changed

5 files changed

+214
-32
lines changed

.github/actions/checkout/action.yml

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

.github/actions/test-coverage/action.yml

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,42 @@ runs:
1717
run: node scripts/aggregate-coverage-results.js
1818
shell: bash
1919

20-
- name: 📥 Download base branch coverage artifact
20+
- name: 🔍 Locate base coverage workflow run
2121
if: github.event_name == 'pull_request'
22+
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
23+
env:
24+
BASE_WORKFLOW: base-coverage.yml
25+
with:
26+
script: |
27+
const workflowId = process.env.BASE_WORKFLOW;
28+
const baseSha = context.payload.pull_request.base.sha;
29+
const { data } = await github.rest.actions.listWorkflowRuns({
30+
owner: context.repo.owner,
31+
repo: context.repo.repo,
32+
workflow_id: workflowId,
33+
head_sha: baseSha,
34+
per_page: 20,
35+
});
36+
const run = data.workflow_runs.find((run) => run.conclusion === 'success');
37+
if (run) {
38+
core.info(`Found base coverage run ${run.id}`);
39+
core.exportVariable('BASE_COVERAGE_RUN_ID', String(run.id));
40+
} else {
41+
core.warning(`No successful base coverage run found for ${baseSha}`);
42+
core.exportVariable('BASE_COVERAGE_RUN_ID', '');
43+
}
44+
45+
- name: 📥 Download base branch coverage artifact
46+
if: github.event_name == 'pull_request' && env.BASE_COVERAGE_RUN_ID != ''
47+
continue-on-error: true
2248
# Downloads the base branch's coverage artifact for comparison
2349
# Finds the workflow run from the base branch commit SHA
24-
# Continues even if artifact doesn't exist (first PR or workflow hasn't run on main yet)
25-
continue-on-error: true
26-
# SECURITY: Pin to commit SHA. Visit https://github.com/dawidd6/action-download-artifact/releases
27-
uses: dawidd6/action-download-artifact@ac66b43f0e6a346234dd65d4d0c8fbb31cb316e5 # v3
50+
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5
2851
with:
2952
name: base-coverage
3053
path: base-coverage
31-
github_token: ${{ inputs.github-token }}
32-
workflow: base-coverage.yml
33-
commit: ${{ github.event.pull_request.base.sha }}
34-
if_no_artifact_found: ignore
54+
github-token: ${{ inputs.github-token }}
55+
run-id: ${{ env.BASE_COVERAGE_RUN_ID }}
3556

3657
- name: 💬 Comment coverage diff
3758
if: github.event_name == 'pull_request'

.github/workflows/base-coverage.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-24.04
1616
steps:
1717
- name: 📥 Checkout Repository
18-
uses: ./.github/actions/checkout
18+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
1919

2020
- name: 💻 Node setup
2121
uses: ./.github/actions/node-setup
@@ -28,9 +28,19 @@ jobs:
2828
run: node scripts/aggregate-coverage-results.js
2929
shell: bash
3030

31+
- name: ♻️ Collect coverage summaries
32+
run: |
33+
rm -rf base-coverage
34+
rsync -a \
35+
--include '*/' \
36+
--include 'coverage-summary.json' \
37+
--exclude '*' \
38+
coverage/ base-coverage/
39+
shell: bash
40+
3141
- name: 📤 Upload coverage artifact
3242
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
3343
with:
3444
name: base-coverage
35-
path: coverage
45+
path: base-coverage
3646
retention-days: 14

.github/workflows/ci.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ubuntu-24.04
1818
steps:
1919
- name: 📥 Checkout Repository
20-
uses: ./.github/actions/checkout
20+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
2121

2222
- name: 💻 Node setup
2323
uses: ./.github/actions/node-setup
@@ -27,10 +27,9 @@ jobs:
2727

2828
licenses:
2929
runs-on: ubuntu-24.04
30-
needs: lint
3130
steps:
3231
- name: 📥 Checkout Repository
33-
uses: ./.github/actions/checkout
32+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
3433

3534
- name: 💻 Node setup
3635
uses: ./.github/actions/node-setup
@@ -40,10 +39,9 @@ jobs:
4039

4140
build:
4241
runs-on: ubuntu-24.04
43-
needs: lint
4442
steps:
4543
- name: 📥 Checkout Repository
46-
uses: ./.github/actions/checkout
44+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
4745

4846
- name: 💻 Node setup
4947
uses: ./.github/actions/node-setup
@@ -54,14 +52,13 @@ jobs:
5452

5553
coverage:
5654
runs-on: ubuntu-24.04
57-
needs: lint
5855
permissions:
5956
actions: read # download base coverage artifact via workflow run APIs
6057
contents: read # checkout
6158
pull-requests: write # comment coverage diff on PRs
6259
steps:
6360
- name: 📥 Checkout Repository
64-
uses: ./.github/actions/checkout
61+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
6562

6663
- name: 💻 Node setup
6764
uses: ./.github/actions/node-setup
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
import { render, screen } from '@testing-library/react';
2+
import {
3+
Select,
4+
SelectContent,
5+
SelectGroup,
6+
SelectItem,
7+
SelectLabel,
8+
SelectSeparator,
9+
SelectTrigger,
10+
SelectValue,
11+
} from '../select';
12+
13+
describe('Select Component', () => {
14+
it('renders Select with data-slot attribute', () => {
15+
render(
16+
<Select>
17+
<SelectTrigger>
18+
<SelectValue placeholder="Choose an option" />
19+
</SelectTrigger>
20+
</Select>
21+
);
22+
23+
const select = screen.getByRole('combobox');
24+
expect(select).toBeInTheDocument();
25+
expect(select).toHaveAttribute('data-slot', 'select-trigger');
26+
});
27+
28+
it('renders SelectTrigger with default size', () => {
29+
render(
30+
<Select>
31+
<SelectTrigger>
32+
<SelectValue placeholder="Select" />
33+
</SelectTrigger>
34+
</Select>
35+
);
36+
37+
const trigger = screen.getByRole('combobox');
38+
expect(trigger).toHaveClass('data-[size=default]:h-9');
39+
expect(trigger).toHaveAttribute('data-size', 'default');
40+
});
41+
42+
it('renders SelectTrigger with small size', () => {
43+
render(
44+
<Select>
45+
<SelectTrigger size="sm">
46+
<SelectValue placeholder="Select" />
47+
</SelectTrigger>
48+
</Select>
49+
);
50+
51+
const trigger = screen.getByRole('combobox');
52+
expect(trigger).toHaveClass('data-[size=sm]:h-8');
53+
expect(trigger).toHaveAttribute('data-size', 'sm');
54+
});
55+
56+
it('applies custom className to SelectTrigger', () => {
57+
render(
58+
<Select>
59+
<SelectTrigger className="custom-trigger">
60+
<SelectValue placeholder="Select" />
61+
</SelectTrigger>
62+
</Select>
63+
);
64+
65+
const trigger = screen.getByRole('combobox');
66+
expect(trigger).toHaveClass('custom-trigger');
67+
});
68+
69+
it('renders SelectValue with placeholder', () => {
70+
render(
71+
<Select>
72+
<SelectTrigger>
73+
<SelectValue placeholder="Choose option" />
74+
</SelectTrigger>
75+
</Select>
76+
);
77+
78+
expect(screen.getByText('Choose option')).toBeInTheDocument();
79+
});
80+
81+
it('renders SelectItem with data-slot attribute', () => {
82+
render(
83+
<Select open>
84+
<SelectTrigger>
85+
<SelectValue />
86+
</SelectTrigger>
87+
<SelectContent>
88+
<SelectItem value="option1">Option 1</SelectItem>
89+
</SelectContent>
90+
</Select>
91+
);
92+
93+
const item = screen.getByText('Option 1');
94+
expect(item).toBeInTheDocument();
95+
expect(item.closest('[data-slot="select-item"]')).toBeInTheDocument();
96+
});
97+
98+
it('renders SelectLabel with data-slot attribute', () => {
99+
render(
100+
<Select open>
101+
<SelectTrigger>
102+
<SelectValue />
103+
</SelectTrigger>
104+
<SelectContent>
105+
<SelectGroup>
106+
<SelectLabel>Category</SelectLabel>
107+
<SelectItem value="opt1">Option 1</SelectItem>
108+
</SelectGroup>
109+
</SelectContent>
110+
</Select>
111+
);
112+
113+
const label = screen.getByText('Category');
114+
expect(label).toBeInTheDocument();
115+
expect(label).toHaveAttribute('data-slot', 'select-label');
116+
});
117+
118+
it('renders SelectGroup with data-slot attribute', () => {
119+
render(
120+
<Select open>
121+
<SelectTrigger>
122+
<SelectValue />
123+
</SelectTrigger>
124+
<SelectContent>
125+
<SelectGroup>
126+
<SelectLabel>Group 1</SelectLabel>
127+
<SelectItem value="opt1">Option 1</SelectItem>
128+
</SelectGroup>
129+
</SelectContent>
130+
</Select>
131+
);
132+
133+
const group = screen.getByText('Group 1').closest('[data-slot="select-group"]');
134+
expect(group).toBeInTheDocument();
135+
});
136+
137+
it('renders SelectSeparator with data-slot attribute', () => {
138+
render(
139+
<Select open>
140+
<SelectTrigger>
141+
<SelectValue />
142+
</SelectTrigger>
143+
<SelectContent>
144+
<SelectItem value="opt1">Option 1</SelectItem>
145+
<SelectSeparator />
146+
<SelectItem value="opt2">Option 2</SelectItem>
147+
</SelectContent>
148+
</Select>
149+
);
150+
151+
const separator = document.querySelector('[data-slot="select-separator"]');
152+
expect(separator).toBeInTheDocument();
153+
expect(separator).toHaveAttribute('data-slot', 'select-separator');
154+
});
155+
156+
it('forwards additional props to SelectTrigger', () => {
157+
render(
158+
<Select>
159+
<SelectTrigger data-testid="custom-select" aria-label="Custom select">
160+
<SelectValue placeholder="Select" />
161+
</SelectTrigger>
162+
</Select>
163+
);
164+
165+
const trigger = screen.getByTestId('custom-select');
166+
expect(trigger).toHaveAttribute('aria-label', 'Custom select');
167+
});
168+
});

0 commit comments

Comments
 (0)