Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEDX-1472: added build action and fixed publish validate #18

Merged
merged 2 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/_test:build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: 🧪 build

on:
push:
branches:
- master
pull_request:
paths:
- __tests__/fixtures/build/**
- .github/workflows/build.yaml
- .github/workflows/_test:build.yaml

jobs:
build:
uses: ./.github/workflows/build.yaml
with:
package-path: __tests__/fixtures/build
27 changes: 27 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
on:
workflow_call:
inputs:
package-path:
description: The path to the package to build
default: '.'
type: string

sdk:
description: See https://github.com/dart-lang/setup-dart
default: 2.19.6
type: string

jobs:
sbom:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dart-lang/setup-dart@v1
with:
sdk: ${{ inputs.sdk }}
- working-directory: ${{ inputs.package-path }}
run: dart pub get
- uses: anchore/sbom-action@v0
with:
path: ${{ inputs.package-path}}
format: cyclonedx-json
13 changes: 10 additions & 3 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,21 @@ jobs:

validate-publish:
runs-on: ubuntu-latest
# only run on release pull requests
if: ${{ startsWith(github.ref, 'refs/head/release') && contains(github.event.sender, 'rmconsole') }}
Comment on lines -64 to -65
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't working, opting for a different approach, calculating the release branchname using the current pubspec.yaml

steps:
- uses: actions/checkout@v4
- uses: dart-lang/setup-dart@v1
with:
sdk: ${{ inputs.sdk }}
- run: dart pub publish --dry-run
- id: analyze-pubspec
working-directory: ${{ inputs.package-path }}
run: |
echo "package_name=$(yq '.name' pubspec.yaml)" >> $GITHUB_OUTPUT
echo "package_version=$(yq '.version' pubspec.yaml)" >> $GITHUB_OUTPUT

- name: Validate Publish
# Only validate the publish for release pull requests, as determined by the branch name
if: github.ref == format('refs/head/release_{0}_{1}', steps.analyze-pubspec.outputs.package_name, steps.analyze-pubspec.outputs.package_version)
run: dart pub publish --dry-run

analyze-additional-checks:
runs-on: ubuntu-latest
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
on:
workflow_call:
inputs:
package-path:
description: The path to the package to publish
default: '.'
type: string

sdk:
description: See https://github.com/dart-lang/setup-dart
default: 2.19.6
Expand All @@ -12,11 +17,16 @@ permissions:
pull-requests: write

jobs:
create-sbom-release-asset:
sbom:
name: Create SBOM Release Asset
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dart-lang/setup-dart@v1
with:
sdk: ${{ inputs.sdk }}
- working-directory: ${{ inputs.package-path }}
run: dart pub get
- name: Publish SBOM to Release Assets
uses: anchore/sbom-action@v0
with:
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/test-unit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ jobs:
has-chrome-platform: ${{ steps.analyze.outputs.HAS_CHROME_PLATFORM }}
steps:
- uses: actions/checkout@v4
- name: Install yq
run: |
sudo wget -O /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
sudo chmod +x /usr/local/bin/yq
- working-directory: ${{ inputs.package-path }}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

github runners have this installed by default actions/runner-images#5144

id: analyze
run: |
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ jobs:
checks:
uses: Workiva/gha-dart-oss/.github/workflows/[email protected]

# Generates sbom and uploads it using anchore/sbom-action
build:
uses: Workiva/gha-dart-oss/.github/workflows/[email protected]
Comment on lines +26 to +27
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we might add more to this one day, for now it just uploads the sbom


# Runs unit tests in both d2js and ddc
unit-tests:
uses: Workiva/gha-dart-oss/.github/workflows/[email protected]
Expand Down
3 changes: 3 additions & 0 deletions __tests__/fixtures/build/lib/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
void main() {
print('Hello World!');
}
7 changes: 7 additions & 0 deletions __tests__/fixtures/build/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: build_test
publish_to: none
environment:
sdk: '>=2.10.0 <3.0.0'

dev_dependencies:
dart_dev: ^4.1.1