How to build, deploy and execute dotnet library on Heroku - heroku

I have .net core 2.1 project library which executes db migrations (using the fluentmigrator). What is the simplest method to to execute this library once I push my code changes (migrations) to github master branch? I was trying to define below yml file and procfile but there is error after the build on release command I have an error:
/bin/sh: 1: dotnet: not found
How to make possible to build and run .net core app using buildpack. Is it possible without using docker?
name: Deploy to Heroku
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
defaults:
run:
working-directory: ./app.db/
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- uses: akhileshns/heroku-deploy#v3.7.8
with:
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: "app-db"
heroku_email: "myemail"
buildpack: "https://github.com/jincod/dotnetcore-buildpack"
appdir: "app.db"
Procfile
release: cd $HOME/heroku_output && dotnet app.db.dll

Yes, heroku dyno is a standard ubuntu (18.04 - 20.04 it depends on stack).
Our team used own buildpack and own build script.
HVG/self-buildpack:
https://github.com/HVG/self-buildpack
Sample Asp.Net Core project:
https://gist.github.com/felegy/8834d26063204d129a7b2893a91f6627

Related

CircleCI setup with Cypress and React-testing-library

I would like to use CircleCi to run my Cypress and react-testing-library tests because I want to test my react app.
On local env I would run (which work fine):
yarn run test to execute my react-testing-library tests
yarn cypress run to execute Cypress test
Now, I have found resources on how to make circleci config.yaml however nothing have worked. For reference link1, link2, link3, link4, link5
Some of the tests failed due to: error cypress#7.1.0: The engine "node" is incompatible with this module. Expected version ">=12.0.0". Got "10.24.1" or wrong cashing or something else. After 20 runs I am clueless, can someone help me, please?
As I was browsing resources I thought this should work for Cypress tests but it did not.
version: 2.1
orbs:
cypress: cypress-io/cypress#1
workflows:
build:
jobs:
- cypress/install:
build: yarn run build # run a custom app build step
yarn: true
- cypress/run:
requires:
- cypress/install
parallel: true # split all specs across machines
parallelism: 4 # use 4 CircleCI machines to finish quickly
yarn: true
group: 'all tests' # name this group "all tests" on the dashboard
start: yarn start # start server before running tests
For those who will search this issue later. I overcome errors:
error cypress#7.1.0: The engine "node" is incompatible with this module. Expected version ">=12.0.0". Got "10.24.1" by not using orb and instead use workflow -> jobs -> steps
fsevents not accessible from jest-haste-map by using yarn instead of npm
Lastly, some of your errors may come from your app (at least in my case react app) taking configuration from .env file that is not uploaded to github and therefore is not checkout to CircleCI docker and therefore during the test of the app will not work.
The working solution that I am using is:
version: 2.1
jobs:
run_tests:
docker:
- image: cypress/base:12
environment:
# this enables colors in the output
TERM: xterm
working_directory: ~/portalo
steps:
- checkout
- run:
name: Install project dependencies
command: yarn install --frozen-lockfile
- run:
name: Compile and start development server on port 3000
command: yarn startOnPort3000Linux
background: true
- run:
name: Wait for development server to start
command: 'yarn wait-on http://localhost:3000'
- run:
name: Run routing tests with react-testing-library via yarn test
command: 'yarn test ~/portalo/src/tests/react-testing-library/routing.test.tsx'
- run:
name: Run e2e tests with Cypruss via cypress run
command: $(yarn bin)/cypress run
workflows:
version: 2.1
build_and_test:
jobs:
- run_tests
Note: wait-on had to be added. In my case by yarn add wait-on
Note2: All steps have to be in a single to have present all installed packages. It could be tweet by using save/restore cache.

How to publish the default workflow(github action) to git hub marketplace?

I have a GitHub action that contains some npm and gulp commands and finally runs a Powershell file. I want to publish this GitHub action on the marketplace so that my team can use it. I can't find a solution to this problem anywhere. I checked the publish Github actions docs, there is no related document.
How do I invoke this action externally?
For instance, How do I convert this simple action so that it can be published to the marketplace?
Sample yml code
# This is a basic workflow to help you get started with Actions
name: CI
on:
push:
branches: [ master ]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: windows-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout#v2
- name: Use Node.js
uses: actions/setup-node#v1
with:
node-version: '10.x'
- name: Install dependencies
run: |
npm install
Thank you
The yaml you've posted here is a workflow, not an action. An action is the code behind the things like uses: actions/checkout#v2 (usually JavaScript, can be Dockerized too). If you're only writing YAML, you're just writing a workflow that invokes actions.
If you want to make your own action, check out the docs.

Issue with circleci and heroku with react app

My CI/CD is: git > cicleci > heroku
I'm using circleci's suggested configuration (attached below)
I have the proper environment variable in circleci.
The first part is working well, however, when I deploy to heroku I can see warnings from devs dependencies like:
./src/hooks/myHook.js
Line 11: React Hook useEffect has a missing dependency: 'x'. Either include it or remove the dependency array react-hooks/exhaustive-deps
which makes me think that React dev is running.
Can anyone help me?
version: 2
jobs:
build:
...
deploy:
docker:
- image: buildpack-deps:trusty
steps:
- checkout
- run:
name: Deploy Master to Heroku
command: |
git push https://heroku:$HEROKU_API_KEY#git.heroku.com/$HEROKU_APP_NAME.git master
workflows:
version: 2
build-deploy:
jobs:
- build
- deploy:
requires:
- build
filters:
branches:
only: master
I'm not sure if you are already but I highly recommend using this Heroku buildpack rather than the standard Heroku Node buildpack: https://github.com/mars/create-react-app-buildpack. This buildpack starts in production by default.
In Heroku go to settings > Buildpacks and click on the Add buildpack, then enter the following url: https://github.com/mars/create-react-app-buildpack.git and save.
However if there is a hook error as above I would fix that issue by adding it into the dependency array in the hook.

CircleCI 2.0 Workflow - Deploy not working

I'm trying to set up a workflow in CircleCI for my React project.
What I want to achieve is to get a job to build the stuff and another one to deploy the master branch to Firebase hosting.
This is what I have so far after several configurations:
witmy: &witmy
docker:
- image: circleci/node:7.10
version: 2
jobs:
build:
<<: *witmy
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
- v1-dependencies-
- run: yarn install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
- run:
name: Build app in production mode
command: |
yarn build
- persist_to_workspace:
root: .
deploy:
<<: *witmy
steps:
- attach_workspace:
at: .
- run:
name: Deploy Master to Firebase
command: ./node_modules/.bin/firebase deploy --token=MY_TOKEN
workflows:
version: 2
build-and-deploy:
jobs:
- build
- deploy:
requires:
- build
filters:
branches:
only: master
The build job always success, but with the deploy I have this error:
#!/bin/bash -eo pipefail
./node_modules/.bin/firebase deploy --token=MYTOKEN
/bin/bash: ./node_modules/.bin/firebase: No such file or directory
Exited with code 1
So, what I understand is that the deploy job is not running in the same place the build was, right?
I'm not sure how to fix that. I've read some examples they provide and tried several things, but it doesn't work. I've also read the documentation but I think it's not very clear how to configure everything... maybe I'm too dumb.
I hope you guys can help me out on this one.
Cheers!!
EDITED TO ADD MY CURRENT CONFIG USING WORKSPACES
I've added Workspaces... but still I'm not able to get it working, after a loooot of tries I'm getting this error:
Persisting to Workspace
The specified paths did not match any files in /home/circleci/project
And also it's a real pain to commit and push to CircleCI every single change to the config file when I want to test it... :/
Thanks!
disclaimer: I'm a CircleCI Developer Advocate
Each job is its own running Docker container (or VM). So the problem here is that nothing in node_modules exists in your deploy job. There's 2 ways to solve this:
Install Firebase and anything else you might need, on the fly, just like you do in the build job.
Utilize CircleCI Workspaces to carry over your node_modules directory from the build job to the deploy job.
In my opinion, option 2 is likely your best bet because it's more efficient.

Circleci task job never executer

I'm having the following circleCi config :
version: 2
jobs:
build:
machine: true
branches:
ignore: gh-pages
steps:
- run: echo "Skipping tests on gh-pages branch"
deployment:
machine:
node:
version: 6.11.2
npm:
version: 3.10.10
branch: ci
steps:
- run: git config --global user.email "<GITHUB_USERNAME>#users.noreply.github.com"
- run: git config --global user.name "<YOUR_NAME>"
- run: echo "machine github.com login <GITHUB_USERNAME> password $GITHUB_TOKEN" > ~/.netrc
- run: cd website && npm install && GIT_USER=<GIT_USER> npm run publish-gh-pages
that aims to deploy a https://docusaurus.io/ site on my github page.
Actually, when the CI runs on the ci branch, it should run the deployment job.
Actually, the deployment job is never triggered and I don't understand why.
I'm well building my ci branch
Here's my circleci build :
This is not running correctly because the config you are using is completely incorrect. There's aspects of CircleCI 2.0 configuration and aspects of CircleCI 1.0 configuration.
I'd recommend choosing one platform (CircleCI 2.0) and then going through the configuration reference for that version. Here's the configuration reference for CircleCI 2.0: https://circleci.com/docs/2.0/configuration-reference/
Feel free to do that, come back and update your question, or post a question at https://discuss.circleci.com.
Respectfully,
Ricardo N Feliciano
Developer Evangelist, CircleCI

Resources