{"id":17056266,"url":"https://github.com/biophoton/travis-ci-integration","last_synced_at":"2026-04-29T22:36:41.613Z","repository":{"id":77494406,"uuid":"109715418","full_name":"BioPhoton/travis-ci-integration","owner":"BioPhoton","description":"Integrating travic-ci","archived":false,"fork":false,"pushed_at":"2017-11-18T15:04:33.000Z","size":123,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-23T06:41:21.498Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BioPhoton.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-06T15:46:03.000Z","updated_at":"2017-11-06T15:48:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"89e53fee-0bf9-4fc5-b6ae-7bc598231a90","html_url":"https://github.com/BioPhoton/travis-ci-integration","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/BioPhoton/travis-ci-integration","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BioPhoton%2Ftravis-ci-integration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BioPhoton%2Ftravis-ci-integration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BioPhoton%2Ftravis-ci-integration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BioPhoton%2Ftravis-ci-integration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BioPhoton","download_url":"https://codeload.github.com/BioPhoton/travis-ci-integration/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BioPhoton%2Ftravis-ci-integration/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274390719,"owners_count":25276408,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-09T02:00:10.223Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T10:23:51.009Z","updated_at":"2026-04-29T22:36:36.571Z","avatar_url":"https://github.com/BioPhoton.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Continuous integration with angular and travis\n#### Implement continuous integration into your angular5 projects with travis and the command line\n\nTravis is a continuous integration platform that provides free usage for open source projects.\nTravis CI supports your development process by automatically building and testing code changes,\nit provides feedback on the success of the change.\nIt can also automate other parts of your development process i.e. managing deployments.\n\nThis script checks the actual status of your travis project.\nIf you initialize travis over the cli it automatically checks the connected git repo and enables it in the platform.\n\nIn this article we will see how to setup a basic travis integration with angular 5.\nWe will start from scratch by creating a repository on github and initialize a new angular project.\nMostly of our work is done over the travis/angular/git cli's, so it should be pretty easy to follow.\n\n**Preconditions:**\n\n- github account\nIf you don't have already create an account on github.com/user\nAfter the confirmation of you account you should be ready to go.\n\n- git bash\nYou need a git cli running on your machine. If you are on a Windows OS you can use [git bash](https://git-for-windows.github.io/).\n\n- travis-cli\nInstall travis-cli on your OS.\nFind the travis-cli project on GitHub under [travis-ci](https://github.com/travis-ci/travis.rb).\n\n- angular cli\nTo install the angular cli follow the steps on the [angular-cli](https://github.com/angular/angular-cli) repository.\n\nOk, ow we have installed all needed cli's and created the required accounts we can start straight away.\nWe will divide this article into two sections, \nFirst we will creation an repository and connecting it to travice and second we will implement a little helper script that checks our travis state. \n\n## Step1 - Create a repository and connect it to travice\n\nOpen `github.com` in your browser. \nAfter log in click on `repositories -\u003e new repository`.\nEnter the required information and save it.\n\n**Create an angular project**\nNext let's initialize the projects angular and npm setup:\n`ng new travis-ci-integration`\n\nFollow the instructions:\n\nYes, No, Yes... Detailed answers here.\n\n`cd .\\travis-ci-integration\\`\nTest it! `npm start` =\u003e should `ng serve` the repo\n\nShow commits =\u003e  `git log`\n\n![Git log initial commit](https://raw.githubusercontent.com/BioPhoton/travis-ci-integration/master/resources/git-log_initial-commit.PNG)\n\n\n**Connect to github**\nOpen up your browser again and visit github.com.\nOn the main page of the repository you will see a button that says clone or download.\nClick this button and copy the https url that is displayed.\n\nNow switch to your console and type in following to add a remote url: \n`git remote add origin https://github.com/[YOUR_USERNAME]/[YOUR_PROJECT_NAME].git`\n\nIf no errors occur push the changes to git:\n`git push -u origin master`\n\n**Setup travis**\nFirst lets create a `.travis-ci.yml` file.\nAgain we will use the cli for this:\n\nin the root folder of the project type:\n`travis init`\n\nYou should see a similar output in your console:\n```\nDetected repository as [YOUR_USERNAME]/[YOUR_PROJECT_NAME], is this correct? |yes| \n```\n\nType `yes` and hit enter.\n\n```\nrepository not known to Travis CI (or no access?)\ntriggering sync: . done\n\nMain programming language used: |Ruby|\n```\n\nType `node` and hit enter\n\n```\n.travis.yml file created!\n[YOUR_USERNAME]/[YOUR_PROJECT_NAME]: enabled :)\n```\n\nNow we should be ready to test it. \nFirst lets open travis.ci in our browser and switch to the repositories section.\nWe should see our project in the list of repositories already enabled.\n\n![Travis project enabled](https://raw.githubusercontent.com/BioPhoton/travis-ci-integration/master/resources/travis-ci_project-enabled.PNG)\n\nOk. Let's see if we did everything right. \nTo our setup type `travis status` in the console.\n\nYou should get following message:\n`no build yet for BioPhoton/travis-ci-integration`\n\n**Configure the .travis.yml file**\n\nNext we will setup the .travis.yml configurations. \n\nOpen up the .travis.yml file and paste in following:\n```\nlanguage: node_js\n\nnode_js:\n- '8.6.0'\n\ninstall:\n  - npm install\n\nscript:\n  - ng build -prod\n```\n\nThis lines will declare the general languages that we use in this project,\nit's versions as well as some additional steps in the travis build lifecycle.\n\nThe full list of steps in the build lifecycle looks like this:\n1. OPTIONAL Install apt addons\n2. OPTIONAL Install cache components\n3. before_install\n4. install\n5. before_script\n6. script\n7. OPTIONAL before_cache (for cleaning up cache)\n8. after_success or after_failure\n9. OPTIONAL before_deploy\n10. OPTIONAL deploy\n11. OPTIONAL after_deploy\n12. after_script\n\nBut in this small example we will focus on just 2 of them which are the 2 main steps for a build, `install` and `script`.\n*install* install any dependencies required\n*script* run the build script\n\nUnder the step `install` we have listed the `npm install` command. Obviously it installs all the npm packages.\nNext we have the `script` step which will execute the `ng build -prod` command. This will build our angular application for production.\n\nSo far so good. Lets push our changes in `.travis.yml` to our repository\n\nIf we type `git status` into the console we will see that the `.travis.yml` is an iuntracked files in the repository. \nLet's add it be running `git add ./.travis.yml` in the console.\n\nIf We now run `git status` again we see that the file is now marked with green and appears under the changes to be committed.\n\nTo commit it just type `git commit -m \"setup travis.yml\"` and if everything is fine push it by running `git push` in the console.\n\nYay!! We successfully configured travis. Let's see how our job runs. To do so head over to your browser an open `https://travis-ci.org/` under your repositories your should see the running job of our repository.\n\n![Git push initial commit](https://raw.githubusercontent.com/BioPhoton/travis-ci-integration/master/resources/git-push_initial.PNG)\n\nWhen its done it should turn green like below.\n\n![Travis job passed](https://raw.githubusercontent.com/BioPhoton/travis-ci-integration/master/resources/travis-ci_running-job.PNG)\n\n\nNow after every new push we should trigger our job at travis again.\nTo test it just make some changes and `git push` them.\n\nNow we can also test if the `travis-cli` works. Let's check the status of our repository on travis by running `travis status`.\nWe should see `build #1 passed` in our console.\n \nSo far so good.\n\nSets sum up what we did:\n- setup an angular project\n- connected it with a github repository\n- initialized travis and configured it in the `.travis.yml` file\n- we start a job on every push\n- and are able to check the travis status over a cli command\n\n## Step 2 - Create script and implement check\n\nNow everything works we can setup a script that checks the build status of our repo\nand perform other actions based on this result.\n\nIn case of invalid status it should exits.\n\n1. checking the job state of or repo on travis.\nThere are two options one with additional information about the build \n`travis status`\nand one without \n`travis status --no-interactive`\n\nLet me explain this command in detail.\n\nEvery Travis command takes three global options:\n\n```\n-h, --help                       Display help\n-i, --[no-]interactive           be interactive and colorful\n-E, --[no-]explode               don't rescue exceptions\n```\n\nThe `--interactive` options determines whether to include additional information and colors in the output or not (no colors on Windows at all).\nIf you don't set this option explicitly, you will run in interactive mode if you invoke the command directly in a shell and in non-interactive mode if you pipe it somewhere.\n\n`travis` as you know is our command related to the travis cli. \n`status` will check the state of the travis job configured in our `travis.yml` file of the current repository. \nAs we want to receive just the state we and no additional information about the build \nwe use the flag `--no-interactive`.\n\nIf every thing works we should see an output similar to this:\n![Travis status command](https://raw.githubusercontent.com/BioPhoton/travis-ci-integration/master/resources/travis-ci_status-commands.PNG)\n\n2. Create travis-check.js file.\nLet's create a `chore` folder in the root that groups all our tooling scripts.\n`cd` into the folder and create a file called `travis-check.js`. \n\nNow we need to do some imports and module exports. Just follow the script below:\n```javascript\n// chore/travis-check.js\n\n'use strict'\n\n// Import utils and promisify exec method\nconst util = require('util')\nconst exec = util.promisify(require('child_process').exec)\n// Import path and create path to the dist folder\nconst path = require('path')\nconst distPath = path.join(__base, 'dist')\n// Stor the value of the job state you want to check.\n// In this case we want to check if the job state is \"passed\"\nconst validState = 'passed'\n\n// Export the function as module\nmodule.exports = travisCheck\n\nfunction travisCheck () {\n  \n}\n\n```\n\n3. Implement check\n```javascript\n// chore/travis-check.js\n...\n\nfunction travisCheck () {\n  // checks the status of the last build of the current repository\n  // --no-interactive disables the interactive mode\n  // source: https://github.com/travis-ci/travis.rb/blob/master/README.md\n  return exec('travis status --no-interactive', {cwd: distPath})\n      .then((result) =\u003e {\n        // Check if the job state is \"passed\"\n        if (result.stdout === validState) {\n          return Promise.resolve(result)\n        } else {\n          return Promise.reject(result)\n        }\n      })      \n}\n```\n\nLets test the script. In your console `cd` into the repos root folder and type `node ./chore/travis-check.js`\n\n4. Use the script\nWhat we now are able to do is perform actions based on the travis state. \nFor example we could publish to npm only if the travis check passes.\n\nTherefor lets create another script called publish-npm.js\nIn this file we required the previously created travis-check module and execute our `npm publish` command in the then block.\n\nWhat we achieved now is that we can only publish on np if the build status of our repository on travis is passed.\n\n```\n// chore/release.js\n\n'use strict'\n// Import util and promisify exec method\nconst util = require('util')\nconst exec = util.promisify(require('child_process').exec)\n\n// import path and build required paths\nconst path = require('path')\nconst base = path.join(__base, 'chore', 'scripts', 'tasks')\n// Import travisCheck\nconst travisCheck = require(path.join(base, 'travis-check'))\n\n// set debug mode\nprocess.env.DEBUG = true\n\n// chain travisCheck and npm publish command\nreturn Promise.resolve()\n    .then(() =\u003e travisCheck())\n    .then(() =\u003e  exec('npm publish', {cwd: path.join(config.libPath, 'dist')}))\n.catch((err) =\u003e console.info('release error'.red, err.red))\n\n```\n\nDone! :-)\nWe finished a minimal setup with travis, checked the build state and can now release our project based on the build state.\n\nYou can find the final code on github.com under [angular5-travis-ci-integreation](https://github.com/BioPhotone/travis-ci-integreation).\nI also did some small refactorings and changed the folder structure, so the final code is a tiny bit more organized then here in the post.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbiophoton%2Ftravis-ci-integration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbiophoton%2Ftravis-ci-integration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbiophoton%2Ftravis-ci-integration/lists"}