Skip to content

Commit

Permalink
fix(workflows): trying to test this
Browse files Browse the repository at this point in the history
Want to try this flow.
  • Loading branch information
trilom authored Feb 25, 2020
2 parents ce3fe3a + 569eb22 commit 8a88412
Show file tree
Hide file tree
Showing 15 changed files with 299 additions and 36 deletions.
3 changes: 3 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Contributing

The repository is released under the MIT license, and follows a standard Github development process, using Github tracker for issues and merging pull requests into master.
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Bug report
about: Create a report to help us improve

---

**Describe the bug**
A clear and concise description of what the bug is.

**Workflow**
If applicable, provide a workflow file to help explain your problem.

**Expected behavior**
A clear and concise description of what you expected to happen.

**Additional context**
Add any other context about the problem here.
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Feature request
about: Suggest an idea for this project

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
14 changes: 14 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
### Type of Change
<!-- What type of change does your code introduce? -->
- [ ] New feature
- [ ] Bug fix
- [ ] Documentation
- [ ] Refactor
- [ ] Chore

### Resolves
- Fixes #[Add issue number here.]

### Describe Changes
<!-- Describe your changes in detail, if applicable. -->
_Describe what this Pull Request does_
12 changes: 12 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# if a push is made into any branch
# this will build node_modules and typescript code
name: Build
on: [push, pull_request]
jobs:
# make sure we can build
build:
name: Build code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: make run
50 changes: 50 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# if a pr is made into master and any further pushes(syncronize)
# this will run prettier every run and auto-commit back the code
# then we will lint and report back any issues
name: Lint
on:
pull_request:
# TODO: CHANGE TO MASTER BRANCH
branches:
- develop
jobs:
# this will lint your code and return any problems to the pr
lint_reviewdog:
name: eslint and reviewdog
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Lint and report
uses: reviewdog/action-eslint@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-review
eslint_flags: 'src/**/*.ts'
# check format and push changes if they exist
format_check_push:
name: prettier
runs-on: ubuntu-latest
# dont run this if pushed from bot or format_check succeeded
needs: lint_reviewdog
if: github.actor != 'trilom-bot'
env:
GITHUB_TOKEN: ${{ secrets.TRILOM_BOT_TOKEN }}
steps:
- uses: actions/checkout@v2
with:
token: ${{ env.GITHUB_TOKEN }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- run: make run
- name: make run COMMAND=format-check code
run: |
make run COMMAND=format-check
- name: make run COMMAND=format and push code if check failed
if: failure()
run: |
make run COMMAND=format
sudo make clean
git config --local user.email "trilom-bot@trailmix.me"
git config --local user.name "trilom-bot"
git commit -m "Add format changes" -a
git push https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.event.pull_request.head.repo.full_name }}.git HEAD:refs/heads/${{ github.event.pull_request.head.ref }} && exit 0
56 changes: 56 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# on push to releases/v1 run semantic release to push npm
# then publish to github package repo
# then push the incremented package.json to releases/v1 which will release to action marketplace
name: Package and deploy release 🎉
on:
push:
# TODO: CHANGE TO releases/v1
branches:
- test/v1
jobs:
# if push to releases/v1 then increment package.json
release_push:
name: Increment and push package.json to release
runs-on: ubuntu-latest
# TODO: CHANGE TO releases/v1 BRANCH
if: github.actor == 'trilom-bot'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.TRILOM_BOT_TOKEN }}
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v2
id: semantic
with:
# TODO: CHANGE TO releases/v1 BRANCH
branch: test/v1
extra_plugins: |
@semantic-release/git
@semantic-release/changelog
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Setup Node.js with GitHub Package Registry
if: steps.semantic.outputs.new_release_published == 'true'
uses: actions/setup-node@v1
with:
node-version: 12
registry-url: 'https://npm.pkg.github.com'
scope: 'trilom'
- name: Publish To GitHub Package Registry
if: steps.semantic.outputs.new_release_published == 'true'
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ env.GITHUB_TOKEN }}
- name: Commit release files
if: steps.semantic.outputs.new_release_published == 'true'
env:
GITHUB_TOKEN: ${{ secrets.TRILOM_BOT_TOKEN }}
# TODO: CHANGE TO releases/v1 BRANCH
run: |
git config --local user.email "trilom-bot@trailmix.me"
git config --local user.name "trilom-bot"
git commit -m "Bump release version 🎉" -a
git push https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git HEAD:refs/heads/test/v${{steps.semantic.outputs.new_release_major_version}}
26 changes: 26 additions & 0 deletions .github/workflows/release_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# on push to master this will build the production code and push to release
name: Release Build
on:
push:
# TODO: CHANGE TO MASTER BRANCH
branches:
- develop
jobs:
# if push to master then build for release, and push to releases/v1 branch
release_build:
name: Build and push to release branch
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.TRILOM_BOT_TOKEN }}
steps:
- uses: actions/checkout@v2
with:
token: ${{ env.GITHUB_TOKEN }}
- run: make run COMMAND=release RELEASE=TRUE
- name: Push release files
# TODO: CHANGE TO releases/v1 BRANCH
run: |
git config --local user.email "trilom-bot@trailmix.me"
git config --local user.name "trilom-bot"
git commit -m "Add release changes ⚙️" -a
git push https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git HEAD:refs/heads/test/v${{steps.semantic.outputs.new_release_major_version}}
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
name: Try a fake release and echo the outputs.
# every week at 5PM GMT run a release test
# on push to release run a release test
name: Semantic-release test
on:
push:
# TODO: CHANGE TO MASTER BRANCH
# TODO: CHANGE TO releases/v1
branches:
- develop
- test/v1
schedule:
- cron: 0 17 * * *
jobs:
test:
name: release
test_release:
name: Test fake release on releases branch
runs-on: ubuntu-latest
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# TODO: CHANGE TO releases/v1 BRANCH
if: github.actor == 'trilom-bot'
steps:
- uses: actions/checkout@v2
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v2
id: semantic
with:
# TODO: CHANGE TO MASTER BRANCH
branch: develop
# TODO: CHANGE TO releases/v1 BRANCH
branch: test/v1
extra_plugins: |
@semantic-release/git
@semantic-release/changelog
dry_run: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Test Outputs
if: steps.semantic.outputs.new_release_published == 'true'
run: |
Expand Down
33 changes: 12 additions & 21 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
name: "build-test"
on: # rebuild any PRs and main branch changes
# if a pr is made into master and any further pushes(syncronize)
# this will run jest
name: Test
on:
pull_request:
push:
# TODO: CHANGE TO MASTER BRANCH
branches:
- master
- 'releases/*'

- develop
jobs:
build: # make sure build/ci work properly
# test with jest
test:
name: jest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- run: |
npm install
npm run all
test: # make sure the action works on a clean machine without building
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- run: |
ls -la
ls -la lib
- uses: ./
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v2
- run: make run
- run: make run COMMAND=test
37 changes: 37 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
SHELL:=/bin/bash
MKFILEPATH:=$(shell pwd)
DOCKER:=node:12@sha256:454651174f54836571258a329788574cf6552bddfd1a7113e769bd9fc3776fe6
ifdef COMMAND
CMD:=$(COMMAND)
endif
ifndef COMMAND
CMD:=build
endif
ifdef RELEASE
CI:=TRUE
endif

IGNORE:=printf '%s\n%s' '**/*' '!.gitignore'

clean.files:
rm -rf lib dist node_modules

clean.create:
mkdir lib dist node_modules && \
$(IGNORE) > lib/.gitignore && \
$(IGNORE) > dist/.gitignore && \
$(IGNORE) > node_modules/.gitignore

clean: clean.files clean.create

run:
docker run \
--mount type=bind,source="$(MKFILEPATH)",target=/code \
$(DOCKER) \
/bin/sh -c 'cd /code && make .yarn COMMAND=$(CMD)' && \
if [ "$(CI)" = "TRUE" ]; then \
rm -rf dist/.gitignore && rm -rf /tmp/node_modules/.gitignore; \
fi

.yarn:
yarn $(CMD)
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,37 @@ jobs:
run: |
cat $HOME/files.txt
```

## Contributing

1. Fork the master branch from the repo.

2. Make your changes in the `src` directory to the typescript files. Once satisfied, or along the way you can run `make run COMMAND=format` to make your code pretty, and `make run COMMAND=lint` to validate it. You must pull the dependencies with `make run COMMAND=build` in order to run these commands.

3. **NOT IMPLEMENTED** Run `make run COMMAND=test` to test your changes prior to releasing.

4. To initiate a release please attempt a PR to the `master` branch, this will trigger the workflow for production testing. Your PR to `master` should not include code in `node_modules`, `dist`, or `lib` these are left for the release process and are in the master for local building.

5. Once PR is accepted and merged into master, this will trigger the workflow to release to `releases/v1` which will persist on the Github Action Marketplace.



```bash
# install project dependencies (including devDependencies)
yarn
# build the project (dist files)
yarn build
# build and lint
# run prettier (this will make your ugly code pretty)
yarn format
# dry-run prettier (this will tell you if your ugly code needs to be made pretty)
yarn format-check
# lint project
yarn lint
# test
yarn jest
# clean duh
yarn clean
```
Loading

0 comments on commit 8a88412

Please sign in to comment.