Lululemon Athletica's (NASDAQ:LULU) stock recently hit an all-time high after its second-quarter numbers beat analysts' expectations. The stock has rallied nearly 70% this year, making it one of the few apparel retailers to flourish as others floundered.

Let's see how Lululemon avoided the industry headwinds of sluggish mall traffic, competition from fast fashion rivals and e-tailers, shifting consumer tastes, and tariffs -- and why its core business keeps firing on all cylinders.

A woman and a man wearing Lululemon apparel.

Image source: Lululemon.

The key numbers

Lululemon's revenue rose 22% annually to $883 million during the quarter, beating estimates by $38 million. Its total comparable store sales rose 15% (17% in constant currency terms), marking its seventh straight quarter of double-digit comps growth. Both growth rates accelerated from the first quarter.

YOY growth

Q2 2018

Q3 2018

Q4 2018

Q1 2019

Q2 2019

Comps

20%

17%

16%

14%

15%

Revenue

25%

21%

26%

20%

22%

YOY = Year-over-year. Source: Lululemon quarterly reports.

In constant currency terms, Lululemon's store comps grew 11% as its digital revenue soared 31%. Direct-to-consumer revenue accounted for 24.6% of its top line, up from 23.1% a year earlier.

Women's comps rose 13% with robust sales of bottoms, while men's comps surged 27% with notable strength in shorts. The company also noted that its sales in Europe rose 35%, and that its Asia-Pacific business remained "very, very strong."

Those growth rates put Lululemon on track to accomplish its five-year goals, which include doubling its digital and men's revenue, quadrupling its international revenue, and growing its comps by the low double-digits annually through the end of 2023.

Expanding gross and operating margins

Lululemon's gross margin expanded two-tenths of a percentage point annually to 55% during the quarter, thanks to lower product costs, a mix of higher-margin products, and fewer markdowns, which offset higher airfreight costs.

That margin expansion, along with a lower effective tax rate (26.4%, compared to 29.5% a year ago), boosted its operating margin half a percentage point to 19%. As a result, Lululemon's EPS jumped 35% to $0.96 and beat expectations by $0.07.

Lululemon's ability to post double-digit comps growth while expanding its margins indicates that it has a loyal customer base (reinforced by community events like free yoga classes) and pricing power. This means that competitors like Gap's (NYSE:GPS) Athleta and Nike (NYSE:NKE) aren't luring away its core customers.

A woman attends a yoga class.

Image source: Lululemon.

Rock-solid guidance with a premium valuation

Lululemon ended the quarter with 460 stores, up from 455 stores in the first quarter. It plans to open 22 new locations in the third quarter and up to 50 new company-operated stores for the full year. 30 of those new locations will be in international markets.

For the third quarter, Lululemon expects its comps to rise by the "low-teens" on a constant currency basis, and for its total revenue to rise 18%-19% annually. It expects its gross margin to "be flat to up modesty" annually, and that its direct exposure to China will remain "relatively small," with only 6% of its finished goods impacted by tariffs. It expects its EPS to rise 20-23%.

For the full year, Lululemon expects its revenue to rise 15-16%, compared to its prior forecast for 13%-14% growth. It expects its EPS to rise 21%-22%.

By comparison, analysts expect Gap's revenue and earnings to decline 1% and 20%, respectively, as the softness of its namesake brand overwhelms the growth of smaller banners like Athleta. Lululemon is also growing at a faster rate than Nike, which is expected to post 8% revenue growth and 17% earnings growth this year.

However, Lululemon's forward P/E of 36 also makes it pricier than Gap and Nike, which trade at 8 and 26 times forward earnings, respectively. Lululemon's forward P/E is also higher than its earnings growth rate -- so investors are paying a premium for its "best in breed" performance.

Does Lululemon still have room to run?

Yet I think that premium is justified. Lululemon dominates its niche of yoga and athletic apparel, it has great growth opportunities in men's apparel and overseas markets, it's well-insulated from tariffs, and its streak of double-digit comps growth and expanding margins won't end anytime soon.

Therefore, investors can consider starting a position in Lululemon at its 52-week high, then accumulating more shares if macro issues rattle the market again.