Skip to content

Commit

Permalink
refactor: workflow improvememts (#56)
Browse files Browse the repository at this point in the history
* adds package target and renames integrate to test
* reorganizes Earthfiles
* consolidates jobs into single reusable workflow
  • Loading branch information
jmgilman authored Oct 25, 2023
1 parent bf23f97 commit 2b483d5
Show file tree
Hide file tree
Showing 12 changed files with 214 additions and 101 deletions.
131 changes: 131 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
on:
workflow_call:
inputs:
aws_ecr_registry:
description: |
The AWS ECR registry that will be used to publish images
required: true
type: string
aws_role_arn:
description: |
The ARN of the AWS role that will be assumed by the workflow. Only
required when configuring a remote Earthly runner or AWS ECR.
required: false
type: string
aws_region:
description: |
The AWS region that will be used by the workflow. Only required when
configuring a remote Earthly runner or AWS ECR.
required: false
type: string
ci_cli_version:
description: |
The version of the CI CLI to use.
required: false
type: string
default: latest
earthly_version:
description: The version of Earthly to use.
required: false
type: string
default: latest
force_artifact:
description: |
When set to true, the workflow will always produce a release artifact
even when the current commit is not tagged.
required: false
type: boolean
default: false
tags:
description: |
A line separated list of additional tags that will be applied to
published images.
required: false
type: string
secrets:
earthly_runner_address:
description: |
The address of the Earthly runner that will be used to build the
Earthly files.
required: false
earthly_runner_secret:
description: |
The ID of the AWS secret holding Earthly remote runner credentials.
This secret must contain the runner address and the necessary TLS
certificates required to authenticate with it. If omitted, a remote
Earthly runner will not be configured.
required: false

jobs:
check:
uses: ./.github/workflows/run.yml
with:
aws_role_arn: ${{ inputs.aws_role_arn }}
aws_region: ${{ inputs.aws_region }}
ci_cli_version: ${{ inputs.ci_cli_version }}
earthly_version: ${{ inputs.earthly_version }}
target: check
secrets:
earthly_runner_address: ${{ secrets.earthly_runner_address }}
earthly_runner_secret: ${{ secrets.earthly_runner_secret }}
build:
uses: ./.github/workflows/run.yml
needs: [check]
with:
aws_role_arn: ${{ inputs.aws_role_arn }}
aws_region: ${{ inputs.aws_region }}
ci_cli_version: ${{ inputs.ci_cli_version }}
earthly_version: ${{ inputs.earthly_version }}
target: check
secrets:
earthly_runner_address: ${{ secrets.earthly_runner_address }}
earthly_runner_secret: ${{ secrets.earthly_runner_secret }}
package:
uses: ./.github/workflows/run.yml
needs: [build, check]
with:
aws_role_arn: ${{ inputs.aws_role_arn }}
aws_region: ${{ inputs.aws_region }}
ci_cli_version: ${{ inputs.ci_cli_version }}
earthly_version: ${{ inputs.earthly_version }}
target: check
secrets:
earthly_runner_address: ${{ secrets.earthly_runner_address }}
earthly_runner_secret: ${{ secrets.earthly_runner_secret }}
test:
uses: ./.github/workflows/run.yml
needs: [build, check, package]
with:
aws_role_arn: ${{ inputs.aws_role_arn }}
aws_region: ${{ inputs.aws_region }}
ci_cli_version: ${{ inputs.ci_cli_version }}
earthly_version: ${{ inputs.earthly_version }}
target: check
secrets:
earthly_runner_address: ${{ secrets.earthly_runner_address }}
earthly_runner_secret: ${{ secrets.earthly_runner_secret }}
release:
uses: ./.github/workflows/release.yml
needs: [build, check, package, test]
with:
aws_role_arn: ${{ inputs.aws_role_arn }}
aws_region: ${{ inputs.aws_region }}
ci_cli_version: ${{ inputs.ci_cli_version }}
earthly_version: ${{ inputs.earthly_version }}
force_artifact: ${{ inputs.force_artifact }}
secrets:
earthly_runner_address: ${{ secrets.earthly_runner_address }}
earthly_runner_secret: ${{ secrets.earthly_runner_secret }}
publish:
uses: ./.github/workflows/publish.yml
needs: [build, check, package, test]
with:
aws_ecr_registry: ${{ inputs.aws_ecr_registry }}
aws_role_arn: ${{ inputs.aws_role_arn }}
aws_region: ${{ inputs.aws_region }}
ci_cli_version: ${{ inputs.ci_cli_version }}
earthly_version: ${{ inputs.earthly_version }}
tags: ${{ inputs.tags }}
secrets:
earthly_runner_address: ${{ secrets.earthly_runner_address }}
earthly_runner_secret: ${{ secrets.earthly_runner_secret }}
47 changes: 2 additions & 45 deletions .github/workflows/dogfood.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,51 +9,8 @@ permissions:
packages: write

jobs:
check:
uses: ./.github/workflows/run.yml
with:
aws_role_arn: arn:aws:iam::332405224602:role/ci
aws_region: eu-central-1
ci_cli_version: 1.3.1
target: check
secrets:
earthly_runner_address: ${{ secrets.EARTHLY_SATELLITE_ADDRESS }}
earthly_runner_secret: ${{ secrets.EARTHLY_RUNNER_SECRET }}
build:
uses: ./.github/workflows/run.yml
needs: [check]
with:
aws_role_arn: arn:aws:iam::332405224602:role/ci
aws_region: eu-central-1
ci_cli_version: 1.3.1
target: build
secrets:
earthly_runner_address: ${{ secrets.EARTHLY_SATELLITE_ADDRESS }}
earthly_runner_secret: ${{ secrets.EARTHLY_RUNNER_SECRET }}
integrate:
uses: ./.github/workflows/run.yml
needs: [build, check]
with:
aws_role_arn: arn:aws:iam::332405224602:role/ci
aws_region: eu-central-1
ci_cli_version: 1.3.1
target: integrate
secrets:
earthly_runner_address: ${{ secrets.EARTHLY_SATELLITE_ADDRESS }}
earthly_runner_secret: ${{ secrets.EARTHLY_RUNNER_SECRET }}
release:
uses: ./.github/workflows/release.yml
needs: [build, check, integrate]
with:
aws_role_arn: arn:aws:iam::332405224602:role/ci
aws_region: eu-central-1
ci_cli_version: 1.3.1
secrets:
earthly_runner_address: ${{ secrets.EARTHLY_SATELLITE_ADDRESS }}
earthly_runner_secret: ${{ secrets.EARTHLY_RUNNER_SECRET }}
publish:
uses: ./.github/workflows/publish.yml
needs: [build, check, integrate]
ci:
uses: ./.github/workflows/ci.yml
with:
aws_ecr_registry: 332405224602.dkr.ecr.eu-central-1.amazonaws.com
aws_role_arn: arn:aws:iam::332405224602:role/ci
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
echo "json=$output" >> $GITHUB_OUTPUT
fi
build:
run:
runs-on: ubuntu-latest
needs: [discover]
if: needs.discover.outputs.json != '[]'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
echo "json=$output" >> $GITHUB_OUTPUT
fi
build:
run:
runs-on: ubuntu-latest
needs: [discover]
if: needs.discover.outputs.json != '[]'
Expand Down Expand Up @@ -131,7 +131,7 @@ jobs:

release:
runs-on: ubuntu-latest
needs: [build]
needs: [run]
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Download artifacts
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
echo "json=$output" >> $GITHUB_OUTPUT
fi
build:
run:
runs-on: ubuntu-latest
needs: [discover]
if: needs.discover.outputs.json != '[]'
Expand Down
17 changes: 11 additions & 6 deletions actions/configure-runner/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,25 @@ src:
COPY --dir src src
COPY .eslintrc.yml tsconfig.json .

package:
build:
FROM +src

RUN npm run package

SAVE ARTIFACT dist dist AS LOCAL dist

check:
FROM +package
test:
FROM +build

RUN npm run format:check
RUN npm run lint
RUN npm test

# Verify the package is not out of date
COPY --dir dist dist_old
RUN npm run package
RUN diff -r dist_old dist
RUN diff -r dist_old dist

check:
FROM +src

RUN npm run format:check
RUN npm run lint
17 changes: 11 additions & 6 deletions actions/discover/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,25 @@ src:
COPY --dir src src
COPY .eslintrc.yml tsconfig.json .

package:
build:
FROM +src

RUN npm run package

SAVE ARTIFACT dist dist AS LOCAL dist

check:
FROM +package
test:
FROM +build

RUN npm run format:check
RUN npm run lint
RUN npm test

# Verify the package is not out of date
COPY --dir dist dist_old
RUN npm run package
RUN diff -r dist_old dist
RUN diff -r dist_old dist

check:
FROM +src

RUN npm run format:check
RUN npm run lint
17 changes: 11 additions & 6 deletions actions/install/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,25 @@ src:
COPY --dir src src
COPY .eslintrc.yml tsconfig.json .

package:
build:
FROM +src

RUN npm run package

SAVE ARTIFACT dist dist AS LOCAL dist

check:
FROM +package
test:
FROM +build

RUN npm run format:check
RUN npm run lint
RUN npm test

# Verify the package is not out of date
COPY --dir dist dist_old
RUN npm run package
RUN diff -r dist_old dist
RUN diff -r dist_old dist

check:
FROM +src

RUN npm run format:check
RUN npm run lint
17 changes: 11 additions & 6 deletions actions/merge/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,25 @@ src:
COPY --dir src src
COPY .eslintrc.yml tsconfig.json .

package:
build:
FROM +src

RUN npm run package

SAVE ARTIFACT dist dist AS LOCAL dist

check:
FROM +package
test:
FROM +build

RUN npm run format:check
RUN npm run lint
RUN npm test

# Verify the package is not out of date
COPY --dir dist dist_old
RUN npm run package
RUN diff -r dist_old dist
RUN diff -r dist_old dist

check:
FROM +src

RUN npm run format:check
RUN npm run lint
17 changes: 11 additions & 6 deletions actions/push/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,25 @@ src:
COPY --dir src src
COPY .eslintrc.yml tsconfig.json .

package:
build:
FROM +src

RUN npm run package

SAVE ARTIFACT dist dist AS LOCAL dist

check:
FROM +package
test:
FROM +build

RUN npm run format:check
RUN npm run lint
RUN npm test

# Verify the package is not out of date
COPY --dir dist dist_old
RUN npm run package
RUN diff -r dist_old dist
RUN diff -r dist_old dist

check:
FROM +src

RUN npm run format:check
RUN npm run lint
Loading

0 comments on commit 2b483d5

Please sign in to comment.