Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
Signed-off-by: Jordan Hollinger <[email protected]>
  • Loading branch information
jhollinger committed Feb 9, 2024
0 parents commit 6243c81
Show file tree
Hide file tree
Showing 42 changed files with 1,743 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @procore-oss/procore-blueprinter
20 changes: 20 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: /
schedule:
interval: "weekly"
timezone: "America/Los_Angeles"
labels:
- "dependabot"
- "dependencies"
- "github-actions"
- package-ecosystem: "bundler"
directory: /
schedule:
interval: "weekly"
timezone: "America/Los_Angeles"
labels:
- "dependabot"
- "dependencies"
- "bundler"
15 changes: 15 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Checklist:

* [ ] I have updated the necessary documentation
* [ ] I have signed off all my commits as required by [DCO](https://github.com/procore-oss/blueprinter-activerecord/blob/main/CONTRIBUTING.md)
* [ ] My build is green

<!--
Note on DCO:
If the DCO check fails, one or more of your commits are not signed off. Please click on the *Details* link next to the DCO action for instructions on how to resolve this.
Note on Versioning:
Maintainers will bump the version and do a release when they are ready to release (possibly multiple merged PRs). Please do not bump the version in your PRs.
-->
40 changes: 40 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Release
on:
workflow_run:
workflows: [Test]
types: [completed]
branches: [main]
workflow_dispatch: # allow manual deployment through GitHub Action UI
jobs:
release:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
steps:
- uses: actions/checkout@v4
- name: Version file changed
id: version-file-changed
uses: tj-actions/changed-files@v42
with:
files: lib/blueprinter-activerecord/version.rb
- name: Set up Ruby
if: ${{ github.event_name == 'workflow_dispatch' || steps.version-file-changed.outputs.any_changed == 'true' }}
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
bundler-cache: true
- name: Installing dependencies
if: ${{ github.event_name == 'workflow_dispatch' || steps.version-file-changed.outputs.any_changed == 'true' }}
run: bundle check --path=vendor/bundle || bundle install --path=vendor/bundle
- name: Build gem file
if: ${{ github.event_name == 'workflow_dispatch' || steps.version-file-changed.outputs.any_changed == 'true' }}
run: bundle exec rake build
- uses: fac/ruby-gem-setup-credentials-action@v2
if: ${{ github.event_name == 'workflow_dispatch' || steps.version-file-changed.outputs.any_changed == 'true' }}
with:
user: ""
key: rubygems
token: ${{secrets.RUBY_GEMS_API_KEY}}
- uses: fac/ruby-gem-push-action@v2
if: ${{ github.event_name == 'workflow_dispatch' || steps.version-file-changed.outputs.any_changed == 'true' }}
with:
key: rubygems
38 changes: 38 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time.
#
# You can adjust the behavior by modifying this file.
# For more information, see:
# https://github.com/actions/stale
name: 'Close stale issues and PRs'
on:
schedule:
- cron: '30 1 * * *' # https://crontab.guru/#30_1_*_*_* (everyday at 0130)

jobs:
stale:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v8
with:
repo-token:
stale-issue-message: >
This issue is stale because it has been open for 30 days with no activity
and will be closed in 14 days unless you add a comment.
stale-pr-message: >
This PR is stale because it has been open for 30 days with no activity
and will be closed in 14 days unless you add a comment.
close-issue-message: >
This issue was closed because it has been stalled for 14 days with no activity.
close-pr-message: >
This PR was closed because it has been stalled for 14 days with no activity.
days-before-issue-stale: 30
days-before-pr-stale: 30
days-before-issue-close: 14
days-before-pr-close: 14
stale-issue-label: 'no-issue-activity'
stale-pr-label: 'no-pr-activity'
exempt-pr-labels: 'dependencies,work-in-progress' # comma separated list of labels
exempt-issue-labels: 'dependencies,work-in-progress' # comma separated list of labels
29 changes: 29 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Test
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
jobs:
test:
strategy:
matrix:
os: [ubuntu-latest]
ruby: ['3.0', '3.1', '3.2']
include:
- os: ubuntu-20.04
ruby: '2.7'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Ruby ${{ matrix.ruby }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Installing dependencies
run: bundle check --path=vendor/bundle || bundle install --path=vendor/bundle
- name: Run tests
run: bundle exec rake
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/Gemfile.lock
/gemfiles/.bundle
/gemfiles/*.gemfile.lock
13 changes: 13 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

appraise "ar-7.1" do
gem "activerecord", "~> 7.1.1"
end

appraise "ar-7.0" do
gem "activerecord", "~> 7.0.8"
end

appraise "ar-6.1" do
gem "activerecord", "~> 6.1.7"
end
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
### 0.5.0 (2024-01-26)

* Adds an "auto" mode that automatically preloads every Blueprint-rendered query
* Adds a "dynamic" mode that allows a single block to decide which Blueprint-rendered queries get preloaded
* Adds two logging extensions for gathering preload stats before and after implementing the Preloader extension

### 0.4.0 (2024-01-18)

* Remove the Blueprinter reflection and extension stubs
* Require Blueprinter >= 1.0

### 0.3.1 (2023-12-04)

* Switches to a real Blueprinter Extension
* Autodetects Blueprinter and view on render
* Allows using `:includes` or `:eager_load` instead of `:preload`

### 0.1.3 (2023-10-16)

* [BUGFIX] Stop preloading when we hit a dynamic blueprint

### 0.1.2 (2023-10-03)

* [BUGFIX] Associations from included views were being missed

### 0.1.1 (2023-09-29)

* [BUGFIX] Open up to all 0.x blueprinter versions

### 0.1.0 (2023-09-25)

* [BUGFIX] Associations weren't being found if they used a custom name (e.g. `association :widget, blueprint: WidgetBlueprint, name: :wdgt`)

## 0.0.1 (2023-09-20)

* Initial release
37 changes: 37 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Contributing to Procore Projects

This document explains the common procedures expected by contributors while submitting code to Procore open source projects.

## Code of Conduct

Please read and abide by the [Code of Conduct](CODE_OF_CONDUCT.md)

## General workflow

Once a GitHub issue is accepted and assigned to you, please follow general workflow in order to submit your contribution:

1. Fork the target repository under your GitHub username.
2. Create a branch in your forked repository for the changes you are about to make.
3. Commit your changes in the branch you created in step 2. All commits need to be signed-off. Check the [legal](#legal) section bellow for more details.
4. Push your commits to your remote fork.
5. Create a Pull Request from your remote fork pointing to the HEAD branch (usually `main` branch) of the target repository.
6. Check the GitHub build and ensure that all checks are green.

## Legal

Procore projects use Developer Certificate of Origin ([DCO](https://GitHub.com/apps/dco/)).

Please sign-off your contributions by doing ONE of the following:

* Use `git commit -s ...` with each commit to add the sign-off or
* Manually add a `Signed-off-by: Your Name <[email protected]>` to each commit message.

The email address must match your primary GitHub email. You do NOT need cryptographic (e.g. gpg) signing.

* Use `git commit -s --amend ...` to add a sign-off to the latest commit, if you forgot.

*Note*: Some projects will provide specific configuration to ensure all commits are signed-off. Please check the project's documentation for more details.

## Tests

Make sure your changes are properly covered by automated tests. We aim to build an efficient test suite that is low cost to maintain and bring value to project. Prefer writing unit-tests over heavy end-to-end (e2e) tests. However, sometimes e2e tests are necessary. If you aren't sure, ask one of the maintainers about the requirements for your pull-request.
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'

gemspec
20 changes: 20 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright 2023 Procore Technologies, Inc.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Loading

0 comments on commit 6243c81

Please sign in to comment.