Replace go-swagger with another version in Windows - go

I am using go1.14.1 and go-swagger version dev in my Windows 10. I installed go-swagger with Installing from source.
I'd like to use go-swagger version 0.25 instead. What is the clean way of replacing dev with 0.25?

The installation process is same as for master (dev) version except you need to do one more additional step which is checking out tag v0.25.0 after cloning the repo to temporary directory:
dir=$(mktemp -d)
git clone https://github.com/go-swagger/go-swagger "$dir"
cd "$dir"
# Checkout version v0.25.0
git checkout v0.25.0
# Continue with installation, instead of
# go install ./cmd/swagger
# use this which just adds version information (current tag) and commit id to binary
go install -ldflags "-X github.com/go-swagger/go-swagger/cmd/swagger/commands.Version=$(git describe --tags) -X github.com/go-swagger/go-swagger/cmd/swagger/commands.Commit=$(git rev-parse HEAD)" ./cmd/swagger
NOTE: If you do just go install ./cmd/swagger it will technically still install v0.25.0 but swagger version subcommand will report it as dev. The version information is just a cosmetic thing passed from git repository down as content of variables in commands package and you can see how authors do it in their CircleCI config file here. Eventually you can add also other flags to get static build (but they don't do that in official Installing from source instructions).
Once done you should have go-swagger v0.25.0 installed in your $GOPATH/bin, verify with:
$ swagger version
version: v0.25.0
commit: f032690aab0634d97e2861a708d8fd9365ba77d2

Related

Building riscv-gnu-toolchain

I'm building the riscv-gnu-toolchain here: https://github.com/riscv-collab/riscv-gnu-toolchain like this:
git clone https://github.com/riscv/riscv-gnu-toolchain.git
cd riscv-gnu-toolchain
git submodule update --init --recursive
export RISCV=/opt/riscv
./configure --prefix="${RISCV}" --enable-multilib
make linux
When compiling during the build of gcc I get this error:
/mnt/data/opt/riscv/sysroot/usr/include/gnu/stubs.h:8:11: fatal error:
gnu/stubs-ilp32.h: No such file or directory
8 | # include <gnu/stubs-ilp32.h>
| ^~~~~~~~~~~~~~~~~~~
I have glibc-devel.i686 and glibc-devel.x86_64 installed on CentOS Stream 8. It's a new install and all up to date. I did follow the instructions and installed the prerequisites.
I think there is something I'm missing in the prerequisites (not listed). Can someone point out what that might be?
I do need to enable multilib since this is for seL4. Here: https://docs.sel4.systems/Hardware/spike.html
I was able to get this to build with the exact steps above:
git clone https://github.com/riscv/riscv-gnu-toolchain.git
cd riscv-gnu-toolchain
git submodule update --init --recursive
export RISCV=/opt/riscv
./configure --prefix="${RISCV}" --enable-multilib
make linux
What I did differently is not building newlib first. I use both versions of toolchain--one with newlib and one with glibc. I guess some left over configs from newlib cause this error.
I wiped out my /opt/riscv directory and the local git repo. I recloned and followed the above steps. It builds after that.

Go application version in modules

How do we add application version in go modules(NOT Dependency version)?I would like to hear from other people on this.I am not sure how to do this
Please follow this guide from the official golang blog for more details.
Let's say you're happy with the API of your module and you want to release v1 as the first stable version. To do this you need to commit latest changes and tag them:
$ git add .
$ git commit -m "feat: changes for v1.0.0"
$ git tag -a v1.0.0 -m 'some release message v1.0.0'
$ git push origin v1.0.0

How to use Travis CI environment variables + .sh script for auto deployment to Github Pages?

UPDATE: This is working, but needs fine-tuning (see below)
Repo Link: https://github.com/oneezy/sweet-element
Travis CI Link: https://travis-ci.org/oneezy/sweet-element
Automation: Travis CI + Github Pages
To explain in more detail what my goals are, I'm trying to simplify my Github + Travis CI workflow w/ 2 environment variables GH_TOKEN + GH_REF stored in a .travis.yml and an executable gpages_build.sh shell script that's used to auto deploy a demo & docs to Github pages on_success: when I git push from command line. I want to create my .travis.yml in such a way that it never has to be manually edited so that it's smart enough to generate the values it needs for GH_REF depending on information that already exists (more details below).
I've followed 2 blog posts that have gotten me to the point I'm at now:
Tutorial 1: How to build Polymer components with Github and Travis CI
Tutorial 2: Automatic github pages deployment for Polymer elements with Travis CI
Current Working Setup ✔
✔ Create "Personal Access Token" from Github
✔ Use travis encrypt command to add GH_TOKEN environment variable to .travis.yml
✔ Add GH_REF: github.com/oneezy/sweet-element environment variable
✔ Use .travis.yml to set everything else up
✔ Use gpages_build.sh to make auto deployment to Github Pages
✔ Make gpages_build.sh executable w/ git update-index --chmod=+x gpages_build.sh
✔ git push and watch it all come together
The Problem ✖
✖ Manually writing GH_REF value in .travis.yml is repetitive/ tedious
✖ Manually writing git update-index --chmod=+x gpages_build.sh is repetitive/ tedious
Possible Solutions & Questions ?
? Can I dynamically generate GH_REF value w/ information that already exists?
? Can I pull information from bower.json or package.json to generate GH_REF value?
? Can I pull information from git config to generate GH_REF value?
? Does Travis CI provide any variables that can be used instead of GH_REF?
? How can I make the gpages_build.sh script executable for all projects?
? Can I execute the gpages_build.sh script from an entire different repo?
? Can I make the gpages_build.sh script executable from the .travis.yml?
The Codes...
.travis.yml (Github Link)
language: node_js
node_js: stable
sudo: required
dist: trusty
addons:
firefox: latest
apt:
sources:
- google-chrome
packages:
- google-chrome-stable
install:
- npm install -g bower polymer-cli
- npm install
- bower install
script:
- xvfb-run polymer test
after_success:
- if [ "$TRAVIS_BRANCH" = "master" ]; then
./gpages_build.sh oneezy sweet-element "Justin O'Neill'" justin#oneezy.com; fi
env:
global:
- GH_REF: github.com/oneezy/sweet-element
- secure: p1OHpnsMIpMjQ4yiFAZJoDZBr/5VHXel+HHC9s8O+MvIqyv5IdxNexkmQKYJneDfYG8XZ/8aNoP4Bsiycysw5POCX1Z9BAwkEBIQ8rdgslzNoWronbtAZUBQAUFxQoVaKt1hBLXNpfyrfRGIfNtAKgA8pekurvIcgjnPmzsNGWr1ztj2y7/5mR7VZZQy3bcM9cZNZLUymyr+RENOXufJnPG2ve/yha/VynUz2mPWEIQPPhg17ar2ICWZL0EZjG6lajR5g83TtSrDxRN2tTGpVWlKVi6udDB/JU+RLt744qhblXwRpFqh1E7r2xUxJWvibQt+UtuRwi6iNJxAy40/XW6Ss/unkwjmRZgU+G98Z3ojJj8Nrp9xah0H2S6M2CH8ySYHnBO6FhunQ3oeXYUn7mYyRiWRz1sjBn0rhWorD67pBFRKIRKFjPPlD9BuI/l/mD8ulgLa7IJFnkt5ZHJx3cWU/BGQ8xLcfor4SgkE4sxlZQWkkn2m2gwvw33JJP6Vv97cs/mgEYORVlBGdG5eAQc1+k18sbGTbbZZojJr5wp4c9VrnDKA7Ztt70ygSHn4etQRogngKPsrKHWnK2q1zBlWoTDq5zjdYZFQt+VC8fET87VUH5Rl7Cn9Chjg8ybY1a4Dq4zKM4uJVKsAYtL+GYNS/kQ/Vgpsd+UTVGx/lDA=
gpages_build.sh (Github Link)
#
# Modified to work with Travis CI automated builds
# Original license follows
#
# #license
# Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
# This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
# The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
# The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
# Code distributed by Google as part of the polymer project is also
# subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
#
# This script pushes a demo-friendly version of your element and its
# dependencies to gh-pages.
# usage gp Polymer core-item [branch]
# Run in a clean directory passing in a GitHub org and repo name
org=$1
repo=$2
name=$3
email=$4
branch=${5:-"master"} # default to master when branch isn't specified
mkdir temp && cd temp
# make folder (same as input, no checking!)
mkdir $repo
git clone "https://${GH_TOKEN}#${GH_REF}" --single-branch
# switch to gh-pages branch
pushd $repo >/dev/null
git checkout --orphan gh-pages
# remove all content
git rm -rf -q .
# use bower to install runtime deployment
bower cache clean $repo # ensure we're getting the latest from the desired branch.
git show ${branch}:bower.json > bower.json
echo "{
\"directory\": \"components\"
}
" > .bowerrc
bower install
bower install $org/$repo#$branch
git checkout ${branch} -- demo
rm -rf components/$repo/demo
mv demo components/$repo/
# redirect by default to the component folder
echo "<META http-equiv="refresh" content=\"0;URL=components/$repo/\">" >index.html
git config user.name $name
git config user.email $email
# send it all to github
git add -A .
git commit -am 'Deploy to GitHub Pages'
git push --force --quiet -u "https://${GH_TOKEN}#${GH_REF}" gh-pages > /dev/null 2>&1
popd >/dev/null
I'm trying to simplify my Github + Travis CI workflow w/ 2 environment variables GH_TOKEN + GH_REF stored in .travis.yml ... used by
git clone "https://${GH_TOKEN}#${GH_REF}" --single-branch
Your script can use the TRAVIS_REPO_SLUG environment variable referenced in the documentation
I managed to do EVERYTHING I wanted to.
My Goals
Automating GH_REF value in gpages_build.sh script w/ the TRAVIS_REPO_SLUG (thanks for the tip #osowskit !)
Writing git update-index --chmod=+x gpages_build.sh once and storing it into it's own repo...when needing it, just bower install it!
✔ The Process
Here's my exact approach I took for creating and testing <custom-elements> w/ Travis CI and auto deploying to Github Pages after a successful build.
gpages_build.sh (script):
In order to move away from having to make my script executable inside every project w/ the git update-index --chmod=+x gpages_build.sh command, I needed to centralize this process inside one handy Github repo (oneezy/build-tools). The benefits of this are:
Only having to make the script executable once
Being able to update the script as needed in one place (not every repo)
Ensuring that when others clone the project, they'll always have the executable file
In order to make the GH_REF variable automatic and not have to write it out each time, Travis CI gives us the TRAVIS_REPO_SLUG variable, which is basically username/repo for whatever Github Repository you're working in. You write it out like this: GH_REF="github.com/${TRAVIS_REPO_SLUG}"
```
# This script pushes a demo-friendly version of your element and its
# dependencies to gh-pages.
# usage gp Polymer core-item [branch]
# Run in a clean directory passing in a GitHub org and repo name
GH_REF="github.com/${TRAVIS_REPO_SLUG}"
org=`echo ${TRAVIS_REPO_SLUG} | cut -f 1 -d /`
repo=`echo ${TRAVIS_REPO_SLUG} | cut -f 2 -d /`
name="Travis CI"
email="builds#oneezy.com"
branch=${3:-"master"} # default to master when branch isn't specified
mkdir temp && cd temp
# make folder (same as input, no checking!)
mkdir $repo
git clone "https://${GH_TOKEN}#${GH_REF}" --single-branch
# switch to gh-pages branch
pushd $repo >/dev/null
git checkout --orphan gh-pages
# remove all content
git rm -rf -q .
# use bower to install runtime deployment
bower cache clean $repo # ensure we're getting the latest from the desired branch.
git show ${branch}:bower.json > bower.json
echo "{
\"directory\": \"components\"
}
" > .bowerrc
bower install
bower install $org/$repo#$branch
git checkout ${branch} -- demo
rm -rf components/$repo/demo
mv demo components/$repo/
# redirect by default to the component folder
echo "<META http-equiv="refresh" content=\"0;URL=components/$repo/\">" >index.html
git config user.name $name
git config user.email $email
# send it all to github
git add -A .
git commit -am 'Deploy to GitHub Pages'
git push --force --quiet -u "https://${GH_TOKEN}#${GH_REF}" gh-pages > /dev/null 2>&1
popd >/dev/null
```
Travis.yml Configuration:
One GOTCHA that was throwing me off here was the GH_TOKEN variable, which is the Personal Access Token you need from Github for read/write ability to your repositories. Due to the power this token has, I needed to encrypt it w/ the Travis CLI (Travis Command Line Tool). travis encrypt GH_TOKEN=********* --add, which will automatically add the encrypted variable to your .travis.yml file. I was under the impression that I could use the same encrypted GH_TOKEN for every repo, but I found out the hard way that's not the case. When you encrypt anything w/ Travis, it appears that you're essentially tieing that encryption to the repository you're in, E.G.: you must travis encrypt GH_TOKEN=********* --add inside every repository. One possible workaround would be to configure an alias/ command inside a config file w/ this information stored inside, but I haven't yet explored the theory.
The next thing to do is bower install -s gpages_build.sh script and run it from .travis.yml w/ ./bower_components/build-tools/gpages_build.sh. This will automatically pull the script from our build-tools repo and run it.
```
language: node_js
node_js: stable
sudo: required
dist: trusty
addons:
firefox: latest
apt:
sources:
- google-chrome
packages:
- google-chrome-stable
cache:
directories:
- node_modules
- "$HOME/.cache/bower"
install:
- npm install -g bower polymer-cli
- npm install
- bower install
script:
- xvfb-run polymer test
after_success:
- if [ ${TRAVIS_PULL_REQUEST} = "false" ] && [ "$TRAVIS_BRANCH" = "master" ]; then
bower install -s oneezy/build-tools && ./bower_components/build-tools/gpages_build.sh;
fi
# DO EVERY TIME:
# travis encrypt GH_TOKEN=**************** --add
# env:
# global:
# secure: ZwNuFN1cryC5dff4c3a1qePkoRZoug+HDiN55dFATTt7Opk20C8SgO+RGEWqYWelFkUN2jhAyoJ91GFMxOyYqbqZP+mQfBaFWgBZoKIcGcDur5in4z6ZaWfw65X03K0HIaaKaunpO4C1d/d++zMhqvudhaJ4JgXJXts5cUdmXGxCIEhKE+mH5d76VK4fbpyrtpewllqHeaiIE88oFZ0L8xQP8K7SUXukvVmE1Re0Kl0UjXjsdSUftcj+gnOcBxqGjVlSjQ9Bk0zmP+2nHYo8Gx=
```
And voila!

Cloud Foundry Ruby Offline Buildpack

I'm trying to get a Ruby Offline buildpack working and am running into this error when deploying an application.
2015-03-31T14:28:56.21-0600 [STG/0] OUT -------> Buildpack version 1.3.0
2015-03-31T14:28:56.22-0600 [STG/0] OUT !
2015-03-31T14:28:56.22-0600 [STG/0] OUT ! No such file or directory - /var/vcap/data/dea_next/admin_buildpacks/fbc8ba1a-0f89-4cd4-bdc6-6b189b326ab6_f80a090fe58f5bba36a6d25dfe86220f7dfcc41d/compile-extensions/bin/translate_dependency_url https://s3-external-1.amazonaws.com/heroku-buildpack-ruby/bundler-1.7.12.tgz
2015-03-31T14:28:56.22-0600 [STG/0] OUT !
Environment:
Linux CentOS 6
Here are the steps I followed:
download the ZIP from https://github.com/cloudfoundry/ruby-buildpack
unzip locally
cd ruby-buildpack
rvm use 2.1.5
BUNDLE_GEMFILE=cf.Gemfile bundle
BUNDLE_GEMFILE=cf.Gemfile bundle exec buildpack-packager cached
cf create-buildpack sjw_ruby_buildpack ruby_buildpack-cached-v1.3.0.zip 11
These instructions came from https://github.com/cloudfoundry-incubator/buildpack-packager/blob/master/doc/disconnected_environments.md
I then deployed the Ruby app as follows:
switched to ruby 2.0.0p643 (2015-02-25 revision 49749) [x86_64-linux]
bundle install
bundle package --all
cf push -b sjw_ruby_buildpack
Failed with the above error message.
This was answered on the Cloud Foundry Dev Group
https://groups.google.com/a/cloudfoundry.org/forum/?utm_medium=email&utm_source=footer#!topic/vcap-dev/9KhpUfuGprk
Here's the relevant section:
It seems like git submodule update --init isn't working, which is actually to be expected if you're using the "Download ZIP" button at the homepage of the ruby-buildpack repo. It sounds like that's how you got the buildpack (" - download the ZIP from https://github.com/cloudfoundry/ruby-buildpack), but Github doesn't provide you with the .git file when you download the source code this way.
To modify the prebuilt buildpack, you could download the ruby_buildpack-cached-v1.3.0.zip file from here, unzip it, modify it, re-zip it and run the cf create-buildpack command to upload it to your Cloud Foundry deployment.
If you need to build it entirely locally, you can try cloning the repo instead:
git clone https://github.com/cloudfoundry/ruby-buildpack.git
cd ruby-buildpack
rm ruby_buildpack-cached-v1.3.0.zip
git submodule update --init
BUNDLE_GEMFILE=cf.Gemfile bundle exec buildpack-packager cached
cf create-buildpack sjw_ruby_buildpack ruby_buildpack-cached-v1.3.0.zip 11
In particular, you should expect the git submodule update --init command NOT to return "fatal: Not a git repository (or any of the parent directories): .git".
Once that's done, try pushing your app again, specifying the buildpack with the -b flag like before, and let us know what happens.

golang and godep : Build\install after a golang dependency update when using godep?

I have followed the instructions # https://github.com/tools/godep regarding updating a dependency but when I go to build\install using the altered version it has not been updated within Godeps/_workspace/pkg
So I have
go get github.com/golang/glog
godep save
godep go install
and I can see
The modification timestamp in Godeps/_workspace/pkg/linux_amd64/github.com/golang/glog.a
The rev commit value in Godeps/Godeps.json
but now when I want to update I follow the instructions
go get github.com/golang/glog
godep update github.com/golang/glog
godep go install
I observe the following
The Godeps/Godeps.json rev commit has been updated
Godeps/_workspace/src/github.com/golang/ source is updated
But the file timestamp for odeps/_workspace/pkg/linux_amd64/github.com/golang/glog.a is not updated hence we are using the previous version
I believe I should add a .gitignore entry for pkg and bin, which means we would do a clean build on a fresh git clone
I know I could do a rm -r on both the pkg and bin directories before the godep go install command
Is this expected behavior ?
Thanks in advance
Pat
FYI
Since golang v1.4 I can now use the -a flag for the go install command, since it now longer tries to rebuild the standard library, see the v1.4 release notes section on the change to the build -a flag
Obviously this does not apply in pre v1.4 as it will attempt to rebuild the standard library packages

Resources