Skip to content
This repository has been archived by the owner on Feb 8, 2019. It is now read-only.

Commit

Permalink
Built a Helper program to automate some tasks for the maintainers.
Browse files Browse the repository at this point in the history
Has an automation task for style checking due to the fact that he gradle checkstyle plugin requires us to store the google_style.xml which would require license additions.
  • Loading branch information
wisebaldone committed Apr 24, 2017
1 parent 050fbb4 commit 3a51151
Show file tree
Hide file tree
Showing 4 changed files with 209 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -21,6 +21,7 @@
war/WEB-INF
*.old
.DS_Store
.helper

### IntelliJ Idea
.idea
Expand Down
33 changes: 33 additions & 0 deletions MAINTAINERS.md
@@ -0,0 +1,33 @@
# Apache Wave

Welcome Apache Wave Maintainer.

This document is your cheat sheet to the resources which are spread around the Apache Wave
repositories and websites. Many of the Apache specific documentation will be on the Wiki linked
below while non-apache related items will be on the website.

### Helpful Links

- [Confluence Wiki](https://cwiki.apache.org/confluence/display/WAVE/Maintainer+Documentation)
- [Maintainer Website](https://incubator.apache.org/wave/maintainers)


### Helper Tool

In the Apache Wave repository is a helper tool which is designed to make our lives easier. The
tool is ever growing to meet the demands of the project. The maintainers website is the stable
location for documentation on the tool.

**Required: You must have go 1.7+ installed.**

With go installed you can run the tool with:

- `go run helper/cli.go`
- `go run helper/cli.go -h`
- `go run helper/cli.go -help`

It will produce files in the `.helper` directory which should not be used for permanent storage
as `-clean` will remove the entire folder.

**Note: Once new website has been made and published formal docs will be located in the
maintainers section.**
84 changes: 84 additions & 0 deletions helper/cli.go
@@ -0,0 +1,84 @@
//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

/*
A Simple helper program to help maintainers run the project.
Current Feature List:
- Runs style checkers
- Runs style formatters ( todo )
- Runs build tools ( todo )
- Runs pre installers ( todo )
- Branch pull requests ( todo )
- Publishes website ( todo )
Command line Flags:
-h | --help : shows the help.
-clean : removes all temporary files.
@author: wisebaldone@apache.org ( Evan Hughes )
*/
package main

import (
"os"
"fmt"
"./style"
"flag"
"log"
)

var openingText string = `
Apache Wave Maintainer Helper!
------------------------------
This tool is written for Apache Wave maintainers and may have undesired affects if used by other
developers. This tool will need certain permissions which are not given to it automatically and will
need to prompt the user for credentials.
Use -h or --help to see the list of commands.
----------------------------------------------------------------------------------------------------
`
/*
Main Helper entry.
*/
func main() {
// Welcome user.
fmt.Println(openingText)
// create temp folder
os.Mkdir(".helper", 0777)

clearFlag := flag.Bool("clear", false, "Clears all temporary files ( deletes .helper )")
styleFlag := flag.Bool("style", false, "Run the style checker on wave and pst projects.")
flag.Parse()

if (*clearFlag) {
clear()
}
if (*styleFlag) {
style.Run()
}
}

// Deletes the .helper folder
func clear() {
log.Println("Removing all temporary files.")
os.RemoveAll(".helper")
}
91 changes: 91 additions & 0 deletions helper/style/style.go
@@ -0,0 +1,91 @@
//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

/*
Commands for running the style checkers.
- Java uses stylechecker.
@author: wisebaldone@apache.org ( Evan Hughes )
*/
package style

import (
"os"
"log"
"net/http"
"io"
"os/exec"
)

const checkStyle = ".helper/checkstyle.jar"

/*
Runs stylechecker based off the Google style guide.
runs on:
wave/src/main/java
pst/src/main/java
*/
func Run() {
_, err := os.Stat(checkStyle)
if os.IsNotExist(err) {
download()
}
run("wave/src/main/java/", ".helper/wave.style.xml")
run("pst/src/main/java/", ".helper/pst.style.xml")
}

// Downloads a set version of checkstyle, current version ( 7.6.1 )
func download() {
out, err := os.Create(checkStyle)
if err != nil {
log.Fatalln(err)
}
log.Println("Downloading checkstyle.")
resp, err := http.Get(
"https://nchc.dl.sourceforge.net/project/checkstyle/checkstyle/" +
"7.6.1/checkstyle-7.6.1-all.jar")
if err != nil {
log.Fatalln("Could not download checkstyle.")
}
defer resp.Body.Close()
_, err = io.Copy(out, resp.Body)
if err != nil {
log.Fatalln(err)
}
}

// Runs the style checker on the input and records the output in xml
func run(directory string, outputFile string) {
log.Printf("Running checkstyle on %s outputting to %s\n", directory, outputFile)
cmd := exec.Command(
"java", "-jar",
checkStyle,
"-c", "/google_checks.xml",
directory,
"-o",
outputFile,
"-f",
"xml")
err := cmd.Run()
if err != nil {
log.Fatalln(err)
}
log.Printf("Finished checking %s\n", directory)
}

0 comments on commit 3a51151

Please sign in to comment.