Skip to content

Commit e27522c

Browse files
committed
Fix tests and simplify workflows
1 parent b115e05 commit e27522c

File tree

4 files changed

+48
-53
lines changed

4 files changed

+48
-53
lines changed

.github/workflows/sync-s3.yml renamed to .github/workflows/build-test-deploy.yml

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: 'Sync S3'
1+
name: 'Build, Test & Deploy'
22

33
concurrency:
44
group: prod_deploy
@@ -14,12 +14,48 @@ on:
1414
- master
1515

1616
jobs:
17+
test:
18+
name: 'Build & Test'
19+
runs-on: ubuntu-20.04
20+
steps:
21+
- uses: actions/checkout@v2
22+
23+
- name: Set Node.js 16.x
24+
uses: actions/[email protected]
25+
with:
26+
node-version: 16.x
27+
28+
- name: Install dependencies
29+
run: npm ci
30+
31+
- name: Lint
32+
run: npm run lint && npm run format-check
33+
34+
- name: Test
35+
run: npm test
36+
37+
- name: Build
38+
run: npm run build
39+
40+
- name: Package
41+
run: npm run package
42+
43+
- name: Compare the expected and actual dist/ directories
44+
run: |
45+
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
46+
echo "Detected uncommitted changes after build. See status below:"
47+
git diff
48+
exit 1
49+
fi
50+
1751
deploy:
18-
name: 'Sync'
52+
name: 'Sync to S3'
1953
runs-on: ubuntu-20.04
54+
needs: test
2055
if: github.actor != 'dependabot[bot]' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
2156
steps:
2257
- uses: actions/checkout@v2
58+
2359
- name: Configure AWS Credentials
2460
uses: aws-actions/configure-aws-credentials@v1
2561
with:

.github/workflows/test.yml

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

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# AWS S3 GitHub Action
22

3-
[![Build & Test](https://github.com/badsyntax/github-action-aws-s3/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/badsyntax/github-action-aws-s3/actions/workflows/test.yml)
4-
[![Sync S3](https://github.com/badsyntax/github-action-aws-s3/actions/workflows/sync-s3.yml/badge.svg?branch=master)](https://github.com/badsyntax/github-action-aws-s3/actions/workflows/sync-s3.yml)
3+
[![Build, Test & Deploy](https://github.com/badsyntax/github-action-aws-s3/actions/workflows/build-test-deploy.yml/badge.svg?branch=master)](https://github.com/badsyntax/github-action-aws-s3/actions/workflows/build-test-deploy.yml)
54
[![CodeQL](https://github.com/badsyntax/github-action-aws-s3/actions/workflows/codeql-analysis.yml/badge.svg?branch=master)](https://github.com/badsyntax/github-action-aws-s3/actions/workflows/codeql-analysis.yml)
65

76
A GitHub Action to sync files to S3.

src/__tests__/s3.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ describe('shouldUploadFile', () => {
4444
srcDir,
4545
'index.html'
4646
);
47+
const s3Key = 'index.html';
4748
const cacheControl = 'no-cache';
4849
const contentType = 'text/html';
4950
const isMultipart = false;
@@ -56,6 +57,7 @@ describe('shouldUploadFile', () => {
5657
const metadata = undefined;
5758
const shouldUpload = await shouldUploadFile(
5859
absoluteFilePath,
60+
s3Key,
5961
cacheControl,
6062
contentType,
6163
isMultipart,
@@ -74,6 +76,7 @@ describe('shouldUploadFile', () => {
7476

7577
const shouldUpload = await shouldUploadFile(
7678
absoluteFilePath,
79+
s3Key,
7780
cacheControl,
7881
contentType,
7982
isMultipart,
@@ -108,6 +111,7 @@ describe('shouldUploadFile', () => {
108111
expect(
109112
await shouldUploadFile(
110113
absoluteFilePath,
114+
s3Key,
111115
cacheControl,
112116
contentType,
113117
isMultipart,
@@ -124,6 +128,7 @@ describe('shouldUploadFile', () => {
124128
expect(
125129
await shouldUploadFile(
126130
absoluteFilePath,
131+
s3Key,
127132
cacheControl,
128133
contentType,
129134
isMultipart,
@@ -143,6 +148,7 @@ describe('shouldUploadFile', () => {
143148
expect(
144149
await shouldUploadFile(
145150
absoluteFilePath,
151+
s3Key,
146152
cacheControl,
147153
contentType,
148154
isMultipart,
@@ -162,6 +168,7 @@ describe('shouldUploadFile', () => {
162168
expect(
163169
await shouldUploadFile(
164170
absoluteFilePath,
171+
s3Key,
165172
cacheControl,
166173
contentType,
167174
isMultipart,
@@ -183,6 +190,7 @@ describe('shouldUploadFile', () => {
183190
expect(
184191
await shouldUploadFile(
185192
absoluteFilePath,
193+
s3Key,
186194
cacheControl,
187195
contentType,
188196
isMultipart,
@@ -202,6 +210,7 @@ describe('shouldUploadFile', () => {
202210
expect(
203211
await shouldUploadFile(
204212
absoluteFilePath,
213+
s3Key,
205214
cacheControl,
206215
contentType,
207216
isMultipart,

0 commit comments

Comments
 (0)