-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactors actions for future naming convention (#6)
- Uses `setup-${language}` for setup actions. - Makes actions specific to IaaS. - Adds patterns to wrap actions into pre-prescribed flows. ## Breaking Changes - Moves npm-setup to setup-node for future consistency - Removes the npm-run action - Renames the deploy-static-assets to deploy-to-s3-bucket
- Loading branch information
1 parent
79100d0
commit f086b69
Showing
45 changed files
with
777 additions
and
482 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- | ||
|
||
name: 'Test deploy-to-s3-bucket action' | ||
description: 'Runs validation agains the deploy-to-s3-bucket action' | ||
|
||
inputs: | ||
aws-account-id: | ||
description: 'The AWS Account id' | ||
required: true | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: 'Install BATS and jq' | ||
shell: bash | ||
run: brew install bats-core jq | ||
|
||
- name: 'Checkout' | ||
uses: actions/checkout@v2 | ||
|
||
- name: 'Use local actions' | ||
uses: ./.github/actions/use-local-actions | ||
|
||
- name: 'Get unique id' | ||
id: id | ||
shell: bash | ||
run: echo "::set-output name=id::$(date '+%s')" | ||
|
||
- name: 'Create archive file' | ||
shell: bash | ||
run: tar -zcvf archive.tgz -C ${{ github.action_path }}/assets . | ||
|
||
- name: 'Run deploy-to-s3-bucket action' | ||
id: unpack | ||
uses: ./actions/deploy-to-s3-bucket | ||
with: | ||
pattern: 'archive.tgz' | ||
s3-bucket: shopsmart-github-actions-tests | ||
s3-bucket-path: ${{ steps.id.outputs.id }} | ||
role-to-assume: arn:aws:iam::${{ inputs.aws-account-id }}:role/github-actions-tests | ||
|
||
- name: 'Configure AWS Credentials' | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-region: 'us-east-1' | ||
role-to-assume: arn:aws:iam::${{ inputs.aws-account-id }}:role/github-actions-tests | ||
|
||
- name: 'Validate' | ||
shell: bash | ||
run: bats -r ${{ github.action_path }}/deploy-to-s3-bucket.bats | ||
env: | ||
S3_BUCKET: shopsmart-github-actions-tests | ||
S3_BUCKET_PATH: ${{ steps.id.outputs.id }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../fixtures/assets |
28 changes: 28 additions & 0 deletions
28
.github/actions/test-deploy-to-s3-bucket/deploy-to-s3-bucket.bats
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env bats | ||
|
||
function setup() { | ||
: | ||
} | ||
|
||
function teardown() { | ||
: | ||
} | ||
|
||
@test "it should have deployed the assets to the s3 bucket" { | ||
run aws s3 cp --recursive "s3://$S3_BUCKET/$S3_BUCKET_PATH" "$BATS_TEST_TMPDIR" | ||
|
||
[ "$status" -eq 0 ] | ||
[ -f "$BATS_TEST_TMPDIR/index.html" ] | ||
[ -f "$BATS_TEST_TMPDIR/style.css" ] | ||
} | ||
|
||
# @test "it should have set the tag on all assets" { | ||
# run aws s3api get-object-tagging \ | ||
# --bucket $S3_BUCKET \ | ||
# --key $S3_BUCKET_PATH/index.html \ | ||
# --no-cli-pager \ | ||
# | jq -r '.TagSet | to_entries[] | select(.key == "version")' | ||
|
||
# [ "$status" -eq 0 ] | ||
# [ "$output" = "$VERSION" ] | ||
# } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
|
||
name: 'Test package-archive action' | ||
description: 'Runs validation agains the package-archive action' | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: 'Install BATS' | ||
shell: bash | ||
run: brew install bats-core | ||
|
||
- name: 'Checkout' | ||
uses: actions/checkout@v2 | ||
|
||
- name: 'Save off action path' | ||
id: path | ||
shell: bash | ||
run: echo "::set-output name=path::${{ github.action_path }}" | ||
|
||
- name: 'Run package-archive action' | ||
id: unpack | ||
uses: ./actions/package-archive | ||
with: | ||
directory: ${{ github.action_path }}/assets | ||
|
||
- name: 'Validate' | ||
shell: bash | ||
run: bats -r ${{ github.action_path }}/package-archive.bats | ||
env: | ||
FILENAME: ${{ steps.unpack.outputs.filename }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../fixtures/assets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env bats | ||
|
||
function setup() { | ||
: | ||
} | ||
|
||
function teardown() { | ||
: | ||
} | ||
|
||
@test "it should have passed on the filename" { | ||
[ -n "$FILENAME" ] | ||
} | ||
|
||
@test "it should package the archive file" { | ||
[ -f "$FILENAME" ] | ||
|
||
run tar -xf "$FILENAME" -C "$BATS_TEST_TMPDIR" . | ||
|
||
[ "$status" -eq 0 ] | ||
[ -f "$BATS_TEST_TMPDIR/index.html" ] | ||
[ -f "$BATS_TEST_TMPDIR/style.css" ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
|
||
name: 'Test setup-node' | ||
description: 'Runs validation agains the setup-node action' | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: 'Install BATS' | ||
shell: bash | ||
run: brew install bats-core | ||
|
||
- name: 'Checkout actions' | ||
uses: actions/checkout@v2 | ||
|
||
- name: 'Checkout hello world project' | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: mike-carey/hello-world-nodejs | ||
path: ./hello-world | ||
|
||
- name: 'Run setup-node action' | ||
id: setup | ||
uses: ./actions/setup-node | ||
with: | ||
node-version: '14' | ||
working-directory: ./hello-world | ||
|
||
- name: 'Validate' | ||
shell: bash | ||
run: bats -r ${{ github.action_path }}/setup-node.bats | ||
env: | ||
DIRECTORY: ./hello-world | ||
NODE_VERSION: ${{ steps.setup.outputs.node-version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bats | ||
|
||
@test "it should have node installed" { | ||
run node --version | ||
|
||
[ "$status" -eq 0 ] | ||
} | ||
|
||
@test "it should have npm installed" { | ||
run npm --version | ||
|
||
[ "$status" -eq 0 ] | ||
} | ||
|
||
@test "it should have installed node_modules" { | ||
[ -d "$DIRECTORY/node_modules" ] | ||
} | ||
|
||
@test "it should have passed along the node version" { | ||
[ -n "$NODE_VERSION" ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
|
||
name: 'Test unpack-archive action' | ||
description: 'Runs validation agains the unpack-archive action' | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: 'Install BATS' | ||
shell: bash | ||
run: brew install bats-core | ||
|
||
- name: 'Checkout' | ||
uses: actions/checkout@v2 | ||
|
||
- name: 'Create archive file' | ||
shell: bash | ||
run: tar -zcvf archive.tgz -C ${{ github.action_path }}/assets . | ||
|
||
- name: 'Run unpack-archive action' | ||
id: unpack | ||
uses: ./actions/unpack-archive | ||
with: | ||
filename: 'archive.tgz' | ||
|
||
- name: 'Validate' | ||
shell: bash | ||
run: bats -r ${{ github.action_path }}/unpack-archive.bats | ||
env: | ||
DESTINATION: ${{ steps.unpack.outputs.destination }} | ||
MIME_TYPE: ${{ steps.unpack.outputs.mime-type }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../fixtures/assets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bats | ||
|
||
@test "it should have passed along the destination" { | ||
[ -n "$DESTINATION" ] | ||
} | ||
|
||
@test "it should have passed along the mime type" { | ||
[ -n "$MIME_TYPE" ] | ||
} | ||
|
||
@test "it should have unpacked the archive file" { | ||
[ -f "$DESTINATION/index.html" ] | ||
[ -f "$DESTINATION/style.css" ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
|
||
name: 'Run deploy-to-s3-bucket action' | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- actions/deploy-to-s3-bucket/* | ||
- actions/unpack-archive/* | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
test-deploy-to-s3-bucket-action: | ||
name: 'Uses the deploy-to-s3-bucket action' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: 'Checkout actions' | ||
uses: actions/checkout@v2 | ||
|
||
- name: 'Test deploy-to-s3-bucket action' | ||
uses: ./.github/actions/test-deploy-to-s3-bucket | ||
with: | ||
aws-account-id: ${{ secrets.AWS_ACCOUNT_ID }} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.